To realize that the media volume can always be adjusted during the Yue Pao Circle running (provided that the button is not disabled in the system settings to adjust the system volume), it is currently known that AudioSession SetActive is YES during the entire running process, but third-party music (NetEase Cloud Music) will cause playback to stop during playback. Use [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionDuckOthers error:nil];
to call
[[AVAudioSession sharedInstance] setActive:NO
withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation
error:&error];
Then call [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil];
This can be achieved, but frequent calls will cause AVAudioSession Error and playback delay. Are there any other ideas?
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