1

我已经使用 AVQueuePlayer 同时播放两个视频,现在我的应用程序出现了一些问题。我想在播放视频时将其静音。但是没有找到设置音量的方法。

谁能帮我在 AVQueuePlayer 中设置音量。

提前致谢

4

2 回答 2

2

AVQueuePlayer只是一个子类AVPlayer,所以设置音量就像在一个AVPlayer应该工作(注意:我还没有测试过)

要了解如何设置音量,AVPlayer请查看

于 2011-06-12T14:59:02.233 回答
0
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];
    }
于 2013-11-28T08:22:01.090 回答