我已经使用 AVQueuePlayer 同时播放两个视频,现在我的应用程序出现了一些问题。我想在播放视频时将其静音。但是没有找到设置音量的方法。
谁能帮我在 AVQueuePlayer 中设置音量。
提前致谢
我已经使用 AVQueuePlayer 同时播放两个视频,现在我的应用程序出现了一些问题。我想在播放视频时将其静音。但是没有找到设置音量的方法。
谁能帮我在 AVQueuePlayer 中设置音量。
提前致谢
AVQueuePlayer
只是一个子类AVPlayer
,所以设置音量就像在一个AVPlayer
应该工作(注意:我还没有测试过)
要了解如何设置音量,AVPlayer
请查看此。
AVAsset *asset;
NSArray *playerTracks;
NSMutableArray *playerParams;
AVMutableAudioMix *muteAudioMix;
for (int k=0; k<[[audio items] count]; k++)
{
asset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:[soundfile objectAtIndex:k+([soundfile count]-[[audio items] count])] ofType:@"mp3"]] options:nil];
playerTracks = [asset tracksWithMediaType:AVMediaTypeAudio];
playerParams = [NSMutableArray array];
for (AVAssetTrack *track in playerTracks) {
AVMutableAudioMixInputParameters *audioInputParams = [AVMutableAudioMixInputParameters audioMixInputParameters];
[audioInputParams setVolume:1.0 atTime:kCMTimeZero];
[audioInputParams setTrackID:[track trackID]];
[playerParams addObject:audioInputParams];
}
muteAudioMix = [AVMutableAudioMix audioMix];
[muteAudioMix setInputParameters:playerParams];
[[[audio items] objectAtIndex:k] setAudioMix:muteAudioMix];
}