我正在开发自定义音频播放器。我正在使用 UISlider 来调节音量。当我在 iPad 上玩时它工作正常。但是当我使用 AirPlay 时音量没有调整。
这是我调整音量的代码。
UISlider* slide = sender;
NSArray *audioTracks = [myPlayer.currentItem.asset tracksWithMediaType:AVMediaTypeAudio];
NSMutableArray *allAudioParams = [NSMutableArray array];
for (AVAssetTrack *track in audioTracks) {
AVMutableAudioMixInputParameters *audioInputParams =[AVMutableAudioMixInputParameters audioMixInputParametersWithTrack:track];
[audioInputParams setVolume:slide.value atTime:myPlayer.currentTime];
[audioInputParams setTrackID:[track trackID]];
[allAudioParams addObject:audioInputParams];
}
AVMutableAudioMix *audioZeroMix = [AVMutableAudioMix audioMix];
[audioZeroMix setInputParameters:allAudioParams];
[myPlayer.currentItem setAudioMix:audioZeroMix];