Mute audio tracks of live streams using AVPlayer

后端 未结 2 1020
野的像风
野的像风 2021-01-06 08:53

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.

2条回答
  •  温柔的废话
    2021-01-06 09:07

    Your assumption is correct. You cannot mute a player that is playing an HTTP Live Stream. I have filed a RADAR on this.

    In my app we control the streams, so we produced a stream with no audio, and an identical stream with audio, and switch between the 2 to turn on and off the sound. It's the best you can do.

    The AVAudioMix solution doesn't work on live streams. I tried. Look at the note on the bottom that says it only works on file based assets: http://developer.apple.com/library/ios/#qa/qa1716/_index.html

    It looks like Mac Developers get a mute property on their AVPlayer, but iOS doesn't have it yet.

    For now, you will have to work around the problem in your streams, if you can.

提交回复
热议问题