我有一个使用 MPMusicPlayerController 播放背景音乐和使用 AVAudioPlayer 播放前景声音的应用程序。我想控制相对音量以使 MPMusicPlayerController 低得多,但设置音量会改变整个系统音量,就像使用手机侧面的按钮一样。有没有办法在不降低系统音量的情况下降低 MPMusicPlayerController 的音量?
MPMusicPlayerController *musicPlayer = [MPMusicPlayerController applicationMusicPlayer];
musicPlayer.volume = 0.1; // at this point the overall system volune has been set to 0.1
[musicPlayer setQueueWithItemCollection:collection];
[musicPlayer play];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&err];
[player prepareToPlay];
[player setVolume: 1.0]; // I want this to be twice as loud as MPMusicPlayerController
[player play];