MPMoviePlayerViewController

MPMoviePlayerViewController

本文介绍了如何在moviePlaybackDidFinish上停止MPMoviePlayerViewController的自动关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过 presentMoviePlayerViewControllerAnimated:以模态方式呈现的MPMoviePlayerViewController会在内容播放完毕时自动解散。

An MPMoviePlayerViewController which is presented modally through presentMoviePlayerViewControllerAnimated: automatically dismisses itself when it's content finishes playing.

I我试图禁用此功能,因为之后我想播放其他内容。但是,即使我使用 [[NSNotificationCenter defaultCenter] addObserver注册到NSNotificationCenter:自选择器:@selector(movieFinishedCallback :)名称:MPMoviePlayerPlaybackDidFinishNotification对象:playerVC.movi​​ePlayer]; 和设置一些其他内容,它仍然会被驳回。

I've tried to disable this, since I want to play other content afterwards. However, even if I register to the NSNotificationCenter with [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:playerVC.moviePlayer]; and set some other content, it still dismisses.

如何阻止MPMoviePlayerViewController自动解除其自身?

How can I stop MPMoviePlayerViewController from automatically dismissing itself?

更新:

作为澄清,这个问题关于删除自动解雇而不是处理残疾问题'完成'按钮。所选答案反映出来。这是设计,因为我们假设开发人员添加他们自己的解雇MPMoviePlayerViewController的方法。但是, @bickster 的回答也会处理完成按钮。

As a clarification, this question is only about removing the automatic dismissal and not about dealing with the disabled 'done' button. The selected answer reflects. This is by design, since we assume the developer adds their own means of dismissing the MPMoviePlayerViewController. However, @bickster's answer deals with the 'done' button as well.

推荐答案

谢谢我发现MPMoviePlayerViewController会自动注册到NSNotificationCenter创建时。您必须先删除此注册,它将自动停止自行解除。

Thanks to this blog article I figured out that MPMoviePlayerViewController automatically registers itself to the NSNotificationCenter upon creation. You have to first remove this registration and it will stop dismissing itself automatically.

// Initialize the movie player view controller with a video URL string
MPMoviePlayerViewController *playerVC = [[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:aVideoUrl]] autorelease];
// Remove the movie player view controller from the "playback did finish" notification observers
[[NSNotificationCenter defaultCenter] removeObserver:playerVC  name:MPMoviePlayerPlaybackDidFinishNotification object:playerVC.moviePlayer];

这篇关于如何在moviePlaybackDidFinish上停止MPMoviePlayerViewController的自动关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 21:01