MPMoviePlayerViewController 拔下耳机时停止播放

发布于 2024-09-28 02:20:59 字数 292 浏览 4 评论 0原文

我目前正在开发一个使用 MPMoviePlayerViewController 和 MPMoviePlayerViewController 的网络电视应用程序。 MPMoviePlayer 可在 iPhone 上播放流媒体视频内容。

我遇到的问题是,一旦我拔掉耳机(在看电视时),播放器就会停止。 由于我没有显示标准控件(上一个按钮、播放/暂停按钮、下一个按钮),而是显示我的自定义控件,用户会被冻结的图片困住,除非他切换到新频道

。如何检测因拔掉耳机而导致的播放中断?

感谢您提前提供的提示和技巧,

山姆

I'm currently developing a web-tv application that uses MPMoviePlayerViewController resp. MPMoviePlayer to playback streaming video content on the iphone.

the issue I've got here is that once i unplug my headphones (while watching tv) the player stops.
Due to the fact that I'm not showing the standard controls (previous button, play/pause button, next button) but my custom controlls, the user is stuck with the frozen picture unless he switches to a new channel..

is there any way to detect a playback interuption caused by unplugging the headphones?

thanks for your tipps and tricks in advance,

sam

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

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

发布评论

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

评论(2

孤星 2024-10-05 02:20:59

我没有直接回答你的问题。但我认为 MPMoviePlayerPlaybackStateDidChangeNotification 足以解决您的问题。收到通知后,从电影播放器​​对象的playbackState 属性获取播放状态并采取适当的操作。

I don't have a direct answer to your question. But I think MPMoviePlayerPlaybackStateDidChangeNotification will be good enough to solve your issue. Once you are notified, Get the playback state from the playbackState property of the movie player object and take appropriate action.

宣告ˉ结束 2024-10-05 02:20:59

用一些代码详细说明已接受的答案:

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(videoPlaybackStateChanged:)
                                             name:MPMoviePlayerPlaybackStateDidChangeNotification
                                           object:moviePlayer];


- (void)videoPlaybackStateChanged :(NSNotification *)notification
{
    if (moviePlayer != nil && [moviePlayer playbackState] == MPMoviePlaybackStatePaused)
    {
        [moviePlayer play];
    }
}

Elaborating on the accepted answer with some code:

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(videoPlaybackStateChanged:)
                                             name:MPMoviePlayerPlaybackStateDidChangeNotification
                                           object:moviePlayer];


- (void)videoPlaybackStateChanged :(NSNotification *)notification
{
    if (moviePlayer != nil && [moviePlayer playbackState] == MPMoviePlaybackStatePaused)
    {
        [moviePlayer play];
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文