Neal Ehardt
Neal Ehardt

Reputation: 10964

Pausing song when a video begins playing (and vice-versa)

I have an app that uses AVPlayer to play songs and a UIWebView to play YouTube videos. When I build it against iOS 5, the audio and video refuse to play together, which I like. Pressing play on one will automatically pause the other, with a nice half-second fade-out.

Now that I'm building against iOS 6, this behavior is gone -- the songs and videos play over each other. How can I get back the iOS 5 behavior?

Upvotes: 4

Views: 307

Answers (1)

whiteagle
whiteagle

Reputation: 1158

add the shared categories in your App delegate:

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

this will limit to only one active audio session

Upvotes: 0

Related Questions