Skip to main content
Version: 2.0.x

Manage On-Screen Participants - iOS

It is important that only the necessary person are present on the screen when livestream is on. To handle this, we will be using the pin and unpin methods of the Participant class.

note

To ensure only the hosts/speakers are shown in the grid, you should use the SPOTLIGHT layout and pin as the priority when starting the interactive livestream.

Let us first explore two methods that we will be using to manage on-screen participants.

pin()

With these method you can pin any participant's Camera, Screen Share or both. This can be useful to identify the participants based on which you can perform rendering participant grid.

unpin()

With these methods you can unpin any participant's Camera, Screen Share or both. This can be useful to reset pin state of the participant.

info

Important Changes iOS SDK in Version v2.2.0

  • The following modes have been deprecated:
    • CONFERENCE has been replaced by SEND_AND_RECV
    • VIEWER has been replaced by SIGNALLING_ONLY

Please update your implementation to use the new modes.

⚠️ Compatibility Notice:
To ensure a seamless meeting experience, all participants must use the same SDK version.
Do not mix version v2.2.0 + with older versions, as it may cause significant conflicts.

Managing On-Screen Participants

  1. If you want to pin all the hosts/speakers automatically, you can do it by listenting to the onMeetingJoined callback and onParticipantModeChanged, where you can pin and unpin based on the mode.
class LiveStreamViewController: ObservableObject {
//...
// Add event listeners and join the meeting
meeting?.addEventListener(self)
//...
}

extension LiveStreamViewController: MeetingEventListener {
func onMeetingJoined() {
guard let localParticipant = self.meeting?.localParticipant else { return }
self.localParticipant = localParticipant
localParticipant.addEventListener(self)
//We will pin the participant if mode is SEND_AND_RECV
if (localParticipant.mode == .SEND_AND_RECV) {
localParticipant.pin()
} else {
localParticipant.unpin()
}
}

func onParticipantModeChanged(participantId: String, mode: VideoSDKRTC.Mode) {
let participant = self.participants.first { $0.id == participantId }
if participant != nil {
//We will pin the participant if mode is SEND_AND_RECV
if (participant?.mode == .SEND_AND_RECV) {
participant?.pin()
} else {
participant?.unpin()
}
}
}
//...
}

API Reference

The API references for all the methods utilized in this guide are provided below.

Got a Question? Ask us on discord