Skip to content

Commit

Permalink
mute/unmute the remote stream if it's play mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mekya committed Mar 7, 2024
1 parent 175640d commit 8caca5c
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions WebRTC-Sample-App/VideoViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,22 @@ class VideoViewController: UIViewController {

@IBAction func audioTapped(_ sender: UIButton!) {
sender.isSelected = !sender.isSelected
self.client?.setMicMute(mute: sender.isSelected, completionHandler: { (mute, error) in
if (error == nil) {
AntMediaClient.printf("Microphone is set to " + (mute ? "muted" : "unmuted"))
}
else {
AntMediaClient.printf("Failed to set microphone status to " + (mute ? "muted" : "unmuted"))
}
});

if (self.client?.getCurrentMode() == .play) {
AntMediaClient.printf("It's in play mode and calling to mute/unmute the incoming stream with enableAudioTrack:\(!sender.isSelected) ");
//mute/unmute the incoming stream audio
self.client?.enableAudioTrack(trackId: self.clientStreamId, enabled: !sender.isSelected);
}
else {
AntMediaClient.printf("It's in publis mode and calling to mute/unmute the local audio to send");

//mute/unmute the microphone for the publisher
self.client?.setAudioTrack(enableTrack: !sender.isSelected);
}




}

@IBAction func videoTapped(_ video: UIButton!) {
Expand Down

0 comments on commit 8caca5c

Please sign in to comment.