This happens, because by default your application is using AVAudioSessionCategorySoloAmbient audio session category.
You could disable auto-lock, but that would decrease battery life. Might be better to continue music playing, regardless of auto-lock:
#import <AVFoundation/AVFoundation.h>Now your application works in same as iPhone music player (iPod). Please read more technical info about Audio Session Programming at Apple iOS Reference Library.
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayback error:NULL];
Is this still the same with ios 5?
ReplyDeleteThat feature was never released. Some testers thought that audio effects in chat application were annoying :) So cannot test that anymore, sorry to say! Should work, but got to try it first.
ReplyDeleteSo does it actually work? I tried here in my app and It doesn't seem to work =(
DeleteWell, it did work pre-iOS5. Haven't tried playing music since then - except previous project should have tested for that! Got to tell my collegue, who's still doing maintenance for old project, while busy in the new one :)
ReplyDeleteBtw iOS5 changed the meaning of screen-saver activation. Now it puts apps to background and should stop music playing - unless your app is requesting "audio" background task capability. Check your info.plist and whether UIBackgroundModes is audio? Can't recall now if you got to restart music playing at applicationDidEnterBackground...