Skip to content

Instantly share code, notes, and snippets.

@digitallysavvy
Last active November 27, 2019 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitallysavvy/53d784c3bbedeff50caed92c3c819f4a to your computer and use it in GitHub Desktop.
Save digitallysavvy/53d784c3bbedeff50caed92c3c819f4a to your computer and use it in GitHub Desktop.
Snippet to toggle the user's microphone within ARSupportBroadcasterViewController and ARSupportAudienceViewController
@IBAction func toggleMic() {
guard let activeMicImg = UIImage(named: "mic") else { return }
guard let disabledMicImg = UIImage(named: "mute") else { return }
if self.micBtn.imageView?.image == activeMicImg {
self.agoraKit.muteLocalAudioStream(true) // Disable Mic using Agora Engine
self.micBtn.setImage(disabledMicImg, for: .normal)
if debug {
print("disable active mic")
}
} else {
self.agoraKit.muteLocalAudioStream(false) // Enable Mic using Agora Engine
self.micBtn.setImage(activeMicImg, for: .normal)
if debug {
print("enable mic")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment