Support audio playback using MPMoviePlayerController and lock screen?

When you watch a video from MPMoviePlayerController, and the user presses the top button to lock the screen, the application goes into sleep mode, as well as the sound from the video.

Is there any way to prevent the sound stop blocking? If not, is there a way to intercept the lock, create a β€œcustom lock” to save some battery but keep playing the video?

+3
source share
1 answer

It looks like you don’t have an audio messaging category set . Set the property to AVAudioSession categoryvalue AVAudioSessionCategoryPlaybackto indicate that the main purpose of the application is to play sound, and therefore it should ignore the screen lock button and the call / tick switch. If you are working with a lower level C API, you will use AudioSessionSetProperty(kAudioSessionCategory_MediaPlayback), but this is the same concept.

+5
source

Source: https://habr.com/ru/post/1719120/


All Articles