iOS - 在导航更改时停止视频
所以这是我的困境,我有一个控制三个视图的导航控制器。第一个视图上有音频,第二个视图图像序列/视频,第三个视图将有音频。
当有人单击“后退”按钮转到编号较低的视图时,如何确保所有这些事情都结束(或只是结束)?
So here is my dilemma, I have a navigation controller that controls three views. The first view has audio on it, the second view image sequences/videos and the third view will have audio.
How can I make sure that all of those things are ended (or just end them) when someone clicks the "Back" button to go to a lower numbered view?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
媒体播放器类(例如音频和视频)通常具有可以实现这一目的的“停止”方法。您可以挂钩 UIViewController 上的 viewWill/Did/Appear/Disapper 方法来了解视图何时/确实变得可见/不可见,并在那时停止媒体播放。我还喜欢在 viewWillUnload 和 dealloc 中对媒体播放器进行 put“stop”方法调用。
media player classes, like audio and video, usually have "stop" methods that will do the trick. You can hook in to the viewWill/Did/Appear/Disapper methods on UIViewController to know when a view is/did become(ing) visible/invisible and stop the media playback at that time. I also like to put put "stop" method calls to media players in viewWillUnload and dealloc.
让自己成为 UINavigationController 的委托并实现它:
Make yourself the delegate of the UINavigationController and implement this:
看看 UINavigationControllerDelegate。它需要方法。
Look at UINavigationControllerDelegate. It has needed methods.