How to mute video played in AVPlayer?
Since iOS7 you can set the AVPlayer isMuted
property to true
.
In Objective C the property is called muted
.
Reference: https://developer.apple.com/documentation/avfoundation/avplayer/1387544-ismuted
This should see you through...
AVURLAsset *asset = [[avPlayer currentItem] asset];NSArray *audioTracks = [asset tracksWithMediaType:AVMediaTypeAudio];// Mute all the audio tracksNSMutableArray *allAudioParams = [NSMutableArray array];for (AVAssetTrack *track in audioTracks) { AVMutableAudioMixInputParameters *audioInputParams = [AVMutableAudioMixInputParameters audioMixInputParameters]; [audioInputParams setVolume:0.0 atTime:kCMTimeZero]; [audioInputParams setTrackID:[track trackID]]; [allAudioParams addObject:audioInputParams];}AVMutableAudioMix *audioZeroMix = [AVMutableAudioMix audioMix];[audioZeroMix setInputParameters:allAudioParams];[[avPlayer currentItem] setAudioMix:audioZeroMix];