Reputation: 409
I have a problem : I added MPMoviePlayerViewController
to detailView
, but when i click on button to open detailView
, MPMoviePlayerViewController
auto play in FUllScreen mode. Now i want when click on button to open DetailView
, MPMoviePlayerViewController
shows Play button and not auto play. Then user click on Play button, MPMoviePlayerViewController must run in FULLScreen by calling [self presentMoviePlayerViewControllerAnimated:moviePlayer];
. How can i do that? Thanks in advance.
movieURL = [NSURL URLWithString:previewString];
moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
moviePlayer.view.frame = CGRectMake(10,130, 275 , 150);
[moviePlayer.moviePlayer prepareToPlay] ;
moviePlayer.moviePlayer.shouldAutoplay = NO;
moviePlayer.wantsFullScreenLayout = NO;
moviePlayer.moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
//[detailview addSubview:moviePlayer.view];
[self presentMoviePlayerViewControllerAnimated:moviePlayer];
If tried above code, moviePlayer auto run in FULLSCREEN mode. Now i want when begin, moviePlayer not autorun in FULLSCREEN mode and when user click on Play button, it'll run in FULLSCREEN mode.
Upvotes: 1
Views: 687
Reputation: 62676
Ask to be notified that the playback state has changed:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(mpChangedPlaybackState:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:nil];
Then check the playback state to see if it's playing:
- (void)mpChangedPlaybackState:(NSNotification *)notification {
if (self.moviePlayer.playbackState == MPMoviePlaybackStatePlaying) {
// the state has changed to 'playing'
}
}
Remember to remove yourself as an observer when you no longer need to know (at the latest, on viewWillDisappear:
)
Upvotes: 1