iPhone OS 4 Multitasking - Playing Audio In background

后端 未结 2 747
旧巷少年郎
旧巷少年郎 2020-12-16 01:46

I am trying to use iPhone OS 4.0\'s multitasking capability. I tried to play audio in the background with no luck. I added UIBackgroundModes property in info.plist and menti

相关标签:
2条回答
  • 2020-12-16 01:54

    It sounds like you didn't set up your Audio Session correctly. From http://developer.apple.com/iphone/library/documentation/AudioVideo/Conceptual/MultimediaPG/UsingAudio/UsingAudio.html :

    For example, when using the default audio session, audio in your application stops when the Auto-Lock period times out and the screen locks. If you want to ensure that playback continues with the screen locked, include the following lines in your application’s initialization code:

    NSError *setCategoryErr = nil;
    NSError *activationErr  = nil;
    [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error:&setCategoryErr];
    [[AVAudioSession sharedInstance] setActive:YES error:&activationErr];
    

    The AVAudioSessionCategoryPlayback category ensures that playback continues when the screen locks. Activating the audio session puts the specified category into effect.

    0 讨论(0)
  • 2020-12-16 01:59

    HI,

    I think this video helps u in solving ur problem... IN WWDC videos they have clearly explained how u can enable the back ground audio... http://developer.apple.com/videos/wwdc/2010/ to view or download these videos u need to have a apple account... and in that see Session 109-Adopting multitasking on iPhone OS, Part2... Hope this will help u..

    ~Raviraja

    0 讨论(0)
提交回复
热议问题