iphone, how to play sound even in silent or mute mode?

后端 未结 3 1745
执笔经年
执笔经年 2020-12-30 17:08

as topic... is it possible ?

Thanks

again, I have attached the code as follows, please check which step is wrong .thanks.

    //@step
AudioS         


        
3条回答
  •  [愿得一人]
    2020-12-30 18:14

    As of iOS 6, there is an alternative method that's more compact than Ramin's answer.

    #import 
    
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback
                                           error:nil];
    

    To allow background audio from other apps to continue playing, add the AVAudioSessionCategoryOptionMixWithOthers option:

    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback
                                     withOptions:AVAudioSessionCategoryOptionMixWithOthers
                                           error:nil];
    

    There's further details in Apple's AVAudioSession Class Reference.

提交回复
热议问题