Search code examples
iosobjective-cavfoundationavplayer

How can I play a video without causing music on iTunes/other audio to pause


I'm using AVPlayer to play a video (open to alternative players). My videos don't have sound. When the video starts, if the IOS device is playing music/audio of some sort, the music/audio pauses even though the video has no sound.

Is there any way to continue playing music while playing a silent movie?


Solution

  • Try preparing the audio session before starting playback:

    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:nil];
    [[AVAudioSession sharedInstance] setActive:NO error:nil];
    
    //... create & configure AVPlayer and start playback