3

I'm running demo Application of WebRTC on iOS.

But there is no sample for mute/unmute like older version of WebRTC.

I have search and found this

How to disable audio in webrtc mobile app(ios) without changing in framework

But newest source doesn't have localStream. It added Audio track and video track. If I set audio track "isEnable" to FALSE. then both 2 user can not hear anything.

Example User A and user B are in a call. What I want is if user A mute, then only user B can not hear the voice.

Appreciate all help

Thor
  • 89
  • 1
  • 13

1 Answers1

6

What do you mean by newest source? ARDAppClient should has the adding of local stream's Audio and Video Component.

Here is the working solution:

static NSString * const kARDAudioTrackId = @"ARDAMSa0";

//Initialization part
_factory = [[RTCPeerConnectionFactory alloc] init];
RTCAudioTrack *_localAudioTrack = [_factory audioTrackWithSource:source
                                            trackId:kARDAudioTrackId];

//For mute and unmute the local stream Audio
- (void)toggleAudioMute {
    self.audioMute = !self.audioMute;
    _localAudioTrack.isEnabled = !self.audioMute;
}
  • It work well. The problem here is set _localAudioTrack as a static variable. Thank you very much for your help. – Thor Apr 03 '18 at 01:31
  • In IOS 12 this way brokes peerConnection – WorieN Sep 27 '18 at 14:00
  • This still shows the orange microphone indicator (https://stackoverflow.com/questions/76388730/how-to-mute-microphone-and-remove-orange-microphone-indicator-with-webrtc-in-ios). Do you have any insight on how to fix this? – förschter Jun 02 '23 at 09:13