I am using AVPlayer to play live stream (m3U8 file). It plays perfectly using AVPlayer but I am not able to mute it.
I am using following code to mute the audio.
NSMutableArray *allAudioParams = [NSMutableArray array];
for (AVPlayerItemTrack *track in _player.currentItem.tracks)
{
if ([track.assetTrack.mediaType isEqual:AVMediaTypeAudio])
{
AVMutableAudioMixInputParameters *audioInputParams = [AVMutableAudioMixInputParameters audioMixInputParameters];
[audioInputParams setVolume:0.0 atTime:kCMTimeZero];
[audioInputParams setTrackID:[track.assetTrack trackID]];
[allAudioParams addObject:audioInputParams];
}
}
AVMutableAudioMix *audioZeroMix = [AVMutableAudioMix audioMix];
[audioZeroMix setInputParameters:allAudioParams];
[[_player currentItem] setAudioMix:audioZeroMix];
With the same code I able to mute the local video files as well as progressive video urls which I am playing in same AVPlayer code.
(may be for live stream video , tracks available in AVPlayer instance can be set volume ZERO but next buffering tracks are fresh with volume, am i right or any other reasons?)
Anybody have any idea on this issue. Any help on this is highly appreciable.