iOS设置静音模式播放声音以及注意点

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_18683985/article/details/86529887

通过下面的设置可以在静音模式下播放声音

    /// 设置静音模式播放声音
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionAllowBluetooth error:nil];
    [[AVAudioSession sharedInstance] setActive:YES error:nil];

注意在应用杀死的情况下停掉播放…

- (void)dealloc {///程序退出
    [self stop];
    ///如果有注册remote得把remote也注销
    [[UIApplication sharedApplication] endReceivingRemoteControlEvents];
}

猜你喜欢

转载自blog.csdn.net/qq_18683985/article/details/86529887