Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Mute AVPlayer which is playing live-stream (m3u8 file)

I am using AVPlayer to play live stream (m3U8 file). It plays perfectly using AVPlayer but I am not able to mute it.

I dont want to mute full ios system, just want to mute the player. 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?)

In Apple documentation it is written that AVAudioMix only supports file-based assets. But I am not getting any replacement for AVAudioMix for livestream-based assets.

Anybody have any idea on this issue. Any help on this is highly appreciable.

iPad 2, iOS 5.1.1

Posted on Jun 26, 2012 12:52 AM

Reply
1 reply

Mute AVPlayer which is playing live-stream (m3u8 file)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.