Reputation: 89
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
Upvotes: 3
Views: 2661
Reputation: 159
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;
}
Upvotes: 6