Hey, you know when youre wathing 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 of the video, is there any way to prevent the lock from stoping 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?
+2
A:
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.
invalidname
2009-10-03 09:39:20
If this works for you, please add the core-audio tag to help people find the answer.
invalidname
2009-10-03 09:39:49
Thank you a lot, it is pretty helpful, however this is available from 3.0 and on, is there a way to do this in previous OS version?
Leg10n
2009-10-04 18:41:54
The low-level C way of doing it is available all the way back to iPhone OS 2.0. The Obj-C AVAudioSession is a convenience added in 3.0.
invalidname
2009-10-05 14:21:13