1

I have use AVQueuePlayer to play two video at the same time, Now I have some problem in my application. I want to mute the video while it is playing . But there is no method found to set volume.

Can any one help me to set volume in AVQueuePlayer.

Thanks in advance

Crazy Developer
  • 3,464
  • 3
  • 28
  • 62

2 Answers2

2

AVQueuePlayer is just a subclass of AVPlayer, so setting the volume just like on an AVPlayer should work (Note: I haven't tested it yet)

To see how to set the volume on an AVPlayer take a look at this.

pablasso
  • 2,479
  • 2
  • 26
  • 32
voidStern
  • 3,678
  • 1
  • 29
  • 32
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];
    }