开发者

MPMoviePlayerController : Trouble stopping video and switching back to iPhone app

I am making an iPhone app, where in there is a requirement for embedding video into the app. I am using MPMoviePlayerController class instance to play the video inside my iPhone app. Now how to stop the video and come back to the application when the video f开发者_Go百科inishes?

Right now even after the video finishes the moviePlayer ( i.e. instance of MPMoviePlayerController) remains open.

Please Help and Suggest.


You to register for an NSNotification that the MPMoviePlayerController sends out when it finishes. Here is an example:

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

A good place to put that is inside "viewDidLoad" of your main ViewController class.

Then inside your method "movieFinishedCallback:" (which gets an NSNotification object passed in as an argument, which you can use to find our more detail about the kind of finishing that happened if you like) you simply dismiss the movieplayercontroller.


You need to check the default property and methods provided for MPMoviePlayerController. You can go through the link http://developer.apple.com/library/ios/#samplecode/MoviePlayer_iPhone/Introduction/Intro.html. You should know about the methods of MPMoviePlayer. There is methods like Play,stop and many more.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜