objective-c - iOS 悦跑圈跑步过程中调节媒体音量,如何实现
怪我咯
怪我咯 2017-05-02 09:32:13
0
1
1209

要实现悦跑圈跑步过程中始终调节媒体音量(前提系统设置中没有禁掉按钮调节系统音量),目前知道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,播放延迟,有没有别的思路?

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(1)
Ty80

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template