要实现悦跑圈跑步过程中始终调节媒体音量(前提系统设置中没有禁掉按钮调节系统音量),目前知道AudioSession在整个跑步过程中SetActive为YES即可,但是第三方音乐(网易云音乐)播放过程中会导致播放停止,使用[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionDuckOthers error:nil];
语音播放完毕在调用
[[AVAudioSession sharedInstance] setActive:NO
withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation
error:&error];
然后再调用 [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];
这样是可以实现,但是频繁调用会导致AVAudioSession Error,播放延迟,有没有别的思路?
PHP中文网2017-05-02 09:34:13
I found the problem. It was my mistake to use AudioSession. There is only one AudioSession for the entire system. When you need to set Active, you need to determine whether there is third-party music playing