I want to create a button that mutes the audio from an AVPlayer.
Why can´t I use .volume with AVPlayer, only with AVAudioPlayer? Is there another way to change the v
I used below code to mute AVPlayer.
float volSet = 0 ;
AVAsset *avAsset = [[avPlayer currentItem] asset] ;
NSArray *audioTracks = [avAsset tracksWithMediaType:AVMediaTypeAudio] ;
NSMutableArray *allAudioParams = [NSMutableArray array] ;
for(AVAssetTrack *track in audioTracks){
AVMutableAudioMixInputParameters *audioInputParams = [AVMutableAudioMixInputParameters audioMixInputParameters] ;
[audioInputParams setVolume:volSet atTime:kCMTimeZero] ;
[audioInputParams setTrackID:[track trackID]] ;
[allAudioParams addObject:audioInputParams];
}
AVMutableAudioMix *audioVolMix = [AVMutableAudioMix audioMix] ;
[audioVolMix setInputParameters:allAudioParams];
[[avPlayer currentItem] setAudioMix:audioVolMix];