Mute/UnMute WebRTC stream while playing in Ant Media's WebRTC iOS SDK

33 Views Asked by At

I'm using WebRTC-iOS-SDK to play the live stream in iOS device. I want to mute/unmute the incoming live stream however I cannot make it even if I try several methods such as setAudioTrack or something. Could you please tell me how I can mute/unmute the audio when I'm playing the stream in WebRTC-iOS-SDK?

1

There are 1 best solutions below

0
faraway On

Let me explain how to mute and unmute the incoming stream.

  • Let's assume that you're publishing a live stream to Ant Media Server with a stream id stream1
  • Let's assume again that you're playing that stream with WebRTC-iOS-SDK as explained in this blog post at Step 4:Play WebRTC Live Stream in iOS
  • Call the following method to mute the playing stream after live stream has started
  self.antMediaClient?.enableAudioTrack(trackId: "stream1", enabled: false);

You can give true in the second parameter to unmute the audio track again.

You can use the enableVideoTrack in the same way. The good thing is that when you call these methods, you make server to enable/disable sending streams. It means that you can decrease network usage if it's important for you.

Cheers