How to make MPMoviePlayerController ignore the mute switch

后端 未结 5 1879
無奈伤痛
無奈伤痛 2021-02-07 02:21

I want to play a video using MPMoviePlayerController but I want it to ignore the mute switch, similar to the behavior of Youtube\'s video player.

Any ideas?

5条回答
  •  不知归路
    2021-02-07 02:43

    For anyone in the future, I know this has been answered already, but I had an issue with playing a video in my app which caused apps like spotify, youtube etc. to stop playing it's audio, so I ending up using this:

    NSError *silentSwitcherror = nil;
    BOOL silentSwitchSuccess = [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:&silentSwitcherror];
    if (silentSwitchSuccess)
    {
    //put whatever video code you are trying to play
    }
    else
    {
    //put how to handle failed instances.
    }
    

提交回复
热议问题