继续玩声音的MPMoviePlayerController并锁定屏幕? [英] Keep playing sound with MPMoviePlayerController and locked screen?

查看:201
本文介绍了继续玩声音的MPMoviePlayerController并锁定屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当你看与的MPMoviePlayerController 视频和用户presses顶部的按钮来锁定屏幕,应用程序进入睡眠状态也是如此的声音从视频。

When you're watching a video with MPMoviePlayerController and the user presses the top button to lock the screen, the app goes to sleep and so does the sound from the video.

有什么办法prevent从停止的声音锁?如果没有,有没有办法拦截锁,创建一个自定义锁,以节省电池,但保持播放视频?

Is there any way to prevent the lock from stopping the sound? If not, is there a way to intercept the lock, to create a "custom lock", to save some battery but keep playing the video?

推荐答案

听起来像是你有没有<一个href=\"http://developer.apple.com/iphone/library/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Configuration/Configuration.html\">set音频会话类。将 AVAudioSession 类别属性 AVAudioSessionCategoryPlayback 来表示该应用程序的主要目的是为了播放音频,因此应该忽略屏幕锁键和响铃/静音开关。如果你使用较低级别的C API时,您将使用 AudioSessionSetProperty(kAudioSessionCategory_MediaPlayback),但它是同一个概念。

Sounds like you haven't set your audio session category. Set the AVAudioSession's category property to AVAudioSessionCategoryPlayback to indicate that the app's major purpose is to play back audio, and it therefore should ignore the screen lock button and ring/silent switch. If you're working with the lower-level C API, you'll be using AudioSessionSetProperty(kAudioSessionCategory_MediaPlayback), but it's the same concept.

这篇关于继续玩声音的MPMoviePlayerController并锁定屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆