Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Valerij Zajcev

macrumors newbie
Original poster
Dec 14, 2010
7
0
Hi,

I am breaking wall with this problem and I beginning to suspect that there is an error in this library.
I created iPhone app that use MPMoviePlayerViewController to play video from stream. Now I have 5 different URL addresses and in my app I have overlay control (ove player) that contains button. When I click button it should change URL and play that URL in player (this should be like switching channels on TV stop previos video and start next from URL). I tried everything and I don't know what to do anymore. Every kind of help is welcome, please. Thanx
This is what I try last:
When I send notification to receiveTestNotification, player close itself and go back to first screen in application.
Code:
- (void) receiveTestNotification:(NSNotification *) notification
{
 NSString *title = [[NSString alloc] initWithFormat:@"%@%@%@", @"http://"];
 NSURL *nurl = [NSURL URLWithString:title];
 NSLog(@"Switching channel...");
 [player.moviePlayer setContentURL:nurl];
}

-(IBAction)btnOk_Click
{ 
 [self initializePlayer];
}

-(void)initializePlayer
{
 NSString *title = [[NSString alloc] initWithFormat:@"%@%@%@", @"http://"];
 NSURL *nurl = [NSURL URLWithString:title];

 player = [[MPMoviePlayerViewController alloc] initWithContentURL:nurl];

 player.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;

 [[NSNotificationCenter defaultCenter]
  addObserver:self selector:@selector(movieFinishedPlaying:)
  name:MPMoviePlayerPlaybackDidFinishNotification
  object:[player moviePlayer]];

 [self presentMoviePlayerViewControllerAnimated:player];

 UIView *mv = player.view;
 [mv addSubview:myOverlayChannelPicker];
 [mv bringSubviewToFront:myOverlayChannelPicker];

 // register this class to observe TestNotification that comes from OverlayChannelPicker
 [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(receiveTestNotification:) 
                                                 name:@"TestNotification"
                                               object:nil];

}

-(void) movieFinishedPlaying: (NSNotification *)note
{
 [[NSNotificationCenter defaultCenter]
  removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification
  object:[player moviePlayer]];

 [player release]; 
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.