Itunes app interruption by my be avoided? Can music continue to play despite my app running? I built an app using the media player framework, is it possible for the intunes app to play music in the background during the sam开发者_JAVA技巧e instance that my app (movieclip) is running. My movie clip contains no audio. What type of AVframework do I need to use in order to allow the itunesapp to continue background playback during my app session?
With AVAudioSession and some code from 71 squared's sound manager:
- (BOOL)isExternalAudioPlaying {
UInt32 audioPlaying = 0;
UInt32 audioPlayingSize = sizeof(audioPlaying);
AudioSessionGetProperty(kAudioSessionProperty_OtherAudioIsPlaying, &audioPlayingSize, &audioPlaying);
return (BOOL)audioPlaying;
}
if (!isExternalAudioPlaying) {
soundCategory = AVAudioSessionCategorySoloAmbient;
audioSessionError = nil;
[audioSession setCategory:soundCategory error:&audioSessionError];
if (audioSessionError)
NSLog(@"WARNING - SoundManager: Error setting the sound category to SoloAmbientSound")
}
If you use an audio session and set its category to AVAudioSessionCategorySoloAmbient, it should continue to play the ipod library's music when you start the app.
精彩评论