Keep playing sound with MPMoviePlayerController and locked screen?

时光怂恿深爱的人放手 提交于 2019-12-02 01:00:08

问题


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.

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?


回答1:


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.



来源:https://stackoverflow.com/questions/1510790/keep-playing-sound-with-mpmovieplayercontroller-and-locked-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!