On / Off Camera - iOS
Any participant can turn their camera on or off in the meeting using below methods.
enableWebcam()
-
By using
enableWebcam()
function ofMeeting
class, local participant can publish video to other participants. -
You can call this method when the local participant is not broadcasting any video to others.
-
You can pass customised video track in
enableWebcam()
by using Custom Video Track. -
Video stream of the participant can be accessed from the
onStreamEnabled
event ofParticipantEventListener
.
disableWebcam()
-
By using
disableWebcam()
function ofMeeting
class, local participant can stop publish video to other participants. -
You can call this method when the local participant is broadcasting any video to others.
From version 2.1.5 of the SDK, you can now use the hardware-accelerated codec (H.264) with VideoSDK.createCameraVideoTrack(), which can enhance compresses video data for efficient transmission over the internet, balancing quality and bandwidth usage.
- Swift
@IBAction func videoButtonTapped(_ sender: Any) {
if !videoEnabled {
// enable webcam/camera
self.meeting?.enableWebcam()
} else {
// disable webcam/camera
self.meeting?.disableWebcam()
}
}
Events associated with enableWebcam
- Every Participant will receive a callback on
onStreamEnabled()
of theParticipant
withStream
object.
Events associated with disableWebcam
- Every Participant will receive a callback on
onStreamDisabled()
of theParticipant
withStream
object.
- Swift
extension MeetingViewController: ParticipantEventListener {
//Callback for when the participant starts a stream
func onStreamEnabled(_ stream: MediaStream, forParticipant participant: Participant) {
if stream.kind = .state(value: .video) {
print("new audio stream enabled")
}
}
//Callback for when the participant stops a stream
func onStreamDisabled(_ stream: MediaStream, forParticipant participant: Participant) {
if stream.kind = .state(value: .video) {
print("new audio stream disabled")
}
}
}
API Reference
The API references for all the methods and events utilised in this guide are provided below.
Got a Question? Ask us on discord