Pause a song while playing a video (and vice versa)

I have an application that uses AVPlayer to play songs and UIWebView to play videos on YouTube. When I create it against iOS 5, audio and video refuse to play together, which I like. Clicking on one of them automatically pauses work with the other, with a pleasant half-second disappearance.

Now that I'm building against iOS 6, this behavior is gone - songs and videos play on top of each other. How can I return the behavior of iOS 5?

+4
source share
1 answer

add general categories to your application delegate:

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

this will limit only one active audio session

0
source

Source: https://habr.com/ru/post/1437486/


All Articles