MPMoviePlayerController:无法停止视频并切换回 iPhone 应用程序

发布于 2024-10-06 12:42:18 字数 251 浏览 0 评论 0原文

我正在制作一个 iPhone 应用程序,其中需要将视频嵌入到应用程序中。我正在使用 MPMoviePlayerController 类实例在我的 iPhone 应用程序中播放视频。现在如何停止视频视频结束后返回应用程序

现在,即使视频结束后,moviePlayer(即 MPMoviePlayerController 的实例)仍保持打开状态。

请帮助和建议。

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 finishes?

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

Please Help and Suggest.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

葮薆情 2024-10-13 12:42:18

您可以注册 MPMoviePlayerController 在完成时发出的 NSNotification。这是一个例子:

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

一个好的地方是把它放在主 ViewController 类的“viewDidLoad”中。

然后在你的方法“movieFinishedCallback:”(它获取一个作为参数传入的 NSNotification 对象,如果你愿意的话,你可以使用它来查找有关所发生的结束类型的更多详细信息)中,你只需关闭 movieplayercontroller 即可。

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.

血之狂魔 2024-10-13 12:42:18

您需要检查为 MPMoviePlayerController 提供的默认属性和方法。您可以访问链接 http://developer.apple。 com/library/ios/#samplecode/MoviePlayer_iPhone/Introduction/Intro.html。您应该了解 MPMoviePlayer 的方法。有播放、停止等方法。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文