Search code examples
ioscocoa-touchmpmovieplayercontrolleravplayer

MPMoviePlayerController want video only, no audio


I'm using video in my app for some tutorials screens. The video has no audio track. I have everything working except if the user is listening to audio already, like from the Music app, the audio is stopped when one of the tutorial videos starts.

Is there a way to only play the video and not affect the audio so the user can continue to enjoy the audio they had playing?

I tried setting [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil]; before [self.player play] but that didn't work. useApplicationAudioSession looked promising but it was deprecated in iOS 6. I've also tried AVPlayer and again setting AVAudioSessionCategoryAmbient before play but no luck.


Solution

  • Try to set [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil]; in application:didFinishLaunchingWithOptions:and try AVPlayer with AVPreviewLayer to play video. Hope this helps.