Skip to content

Conference

Adnan Arnautović edited this page Jan 26, 2023 · 1 revision

id()

Description

Returns a unique identifier of the conference room on Infobip RTC platform.

Arguments

  • none

Returns

Example

let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let conference = infobipRTC.joinConference('conference-id', ConferenceOptions.builder().setAudio(true).build());
console.log(`Conference ID: ${conference.id()}`);



leave()

Description

Leaves the conference room, which results in the left event on the side that left the conference, and all other participants in conference receive the user-left event.

Arguments

  • none

Returns

  • none

Example

let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let conference = infobipRTC.joinConference('conference-id', ConferenceOptions.builder().setAudio(true).build());
conference.leave();



on(eventName, eventHandler)

Description

Configures the event handler for conference events.

Arguments

  • eventName: string - Name of call event. Allowed values are: joined, left, error, reconnecting, reconnected, user-joined, user-left , user-muted, user-unmuted, local-video-added, local-video-removed, local-video-updated, user-video-added and user-video-removed.

  • eventHandler: any - Function that will be called when specified event occurs, with exactly one parameter being passed to the function containing event information. Depending on the event, the passed parameter will contain a set of fields that will describe the event, namely:

    • joined - Fires when user joins the conference room. Other conference participants receive user-joined events in that case. It contains stream with audio media stream and users list (instances of ConferenceUser class) with already joined users in the conference room.

      event = {stream: streamObject, users: [{identity: 'alice', muted: false, talking: false}]}
    • left - Fires when user leaves the conference room. Other conference participants receive user-left events in that case. It contains no fields.

      event = {}
    • error - Fires whenever any error occurs. It contains no fields.

      event = {}
    • reconnecting - Fires when user leaves the conference room due to issues with the connectivity, and the platform itself will try to reconnect him to the same conference room. It contains no fields.

      event = {}
    • reconnected - Fires when user is reconnected to the conference room. Other conference participants receive user-joined events in that case. It contains stream with audio media stream and users list (instances of ConferenceUser class) with already joined users in the conference room.

      event = {stream: streamObject, users: [{identity: 'alice', muted: false, talking: false}]}
    • user-joined - Fires when another user joins the conference room. It contains user (instance of ConferenceUser class) field.

      event = {user: {identity: 'alice', muted: false, talking: false}}
    • user-left - Fires when another user leaves the conference room. It contains user (instance of ConferenceUser class) field.

      event = {user: {identity: 'alice', muted: false, talking: false}}
    • user-muted - Fires when another user mutes themselves. It contains user (instance of ConferenceUser class) field.

      event = {user: {identity: 'alice', muted: false, talking: false}}
    • user-unmuted - Fires when another user unmutes themselves. It contains user (instance of ConferenceUser class) field.

      event = {user: {identity: 'alice', muted: false, talking: false}}
    • user-talking - Fires when another user starts talking. It contains user (instance of ConferenceUser class) field.

      event = {user: {identity: 'alice', muted: false, talking: false}}
    • user-stopped-talking - Fires when another user stops talking. It contains user (instance of ConferenceUser class) field.

      event = {user: {identity: 'alice', muted: false, talking: false}}
    • local-camera-video-added - Fires when user turns on camera video. Other conference participants receive user-camera-video-added event in that case. It contains stream field with local video media stream.

      event = {stream: streamObject}
    • local-camera-video-updated - Fires when user changes video input device. It contains stream field with local video media stream.

      event = {stream: streamObject}
    • local-camera-video-removed - Fires when user turns off camera video. Other conference participants receive user-camera-video-removed event in that case. It contains no fields.

      event = {}
    • local-screenshare-added - Fires when user starts sharing screen. Other conference participants receive user-screenshare-added event in that case. It contains stream field with local video media stream.

      event = {stream: streamObject}
    • local-screenshare-removed - Fires when user stops sharing screen. Other conference participants receive user-screenshare-removed event in that case. It contains no fields.

      event = {}
    • user-camera-video-added - Fires when another user turns on camera video. It contains user (instance of ConferenceUser class) field and the stream with remote video media stream.

      event = {user: {identity: 'alice', muted: false, talking: false}, stream: streamObject}
    • user-camera-video-removed - Fires when another user turns off camera video. It contains user (instance of ConferenceUser class) field.

      event = {user: {identity: 'alice', muted: false, talking: false}}
    • user-screenshare-added - Fires when another user starts sharing screen. It contains user (instance of ConferenceUser class) field and the stream with remote video media stream.

      event = {user: {identity: 'alice', muted: false, talking: false}, stream: streamObject}
    • user-screenshare-removed - Fires when another user stops sharing screen. It contains user (instance of ConferenceUser class) field.

      event = {user: {identity: 'alice', muted: false, talking: false}}

Returns

  • none

Example

Let's assume you have an audio HTML element with the id conferenceAudio and video HTML elements with the ids localVideo and localScreenShare.

When you receive the joined event from our SDK, you will have audio stream in this event, which you need to set as a source on your corresponding HTML element.

Upon turning your local video on (camera or screen share), you will receive the local-camera-video-added /local-screenshare-added event from our SDK with local video streams in it, which you need to set as a source on your corresponding HTML elements.

let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let conference = infobipRTC.joinConference('conference-demo', ConferenceOptions.builder().audio(true).video(false).build());

conference.on('joined', function (event) {
    $('#conferenceAudio').srcObject = event.stream;
    var users = event.users.map(user => user.identity).join(", ");
    console.log(`You have joined the conference with ${event.users.length} more participants: ${users}`);
});
conference.on('left', function (event) {
    console.log('You have left the conference.');
});
conference.on('error', function (event) {
    console.log('Error!');
});
conference.on('user-joined', function (event) {
    console.log(`${event.user.identity} joined the conference.`);
});
conference.on('user-left', function (event) {
    console.log(`${event.user.identity} left the conference.`);
});
conference.on('user-muted', function (event) {
    console.log(`${event.user.identity} muted.`);
});
conference.on('user-unmuted', function (event) {
    console.log(`${event.user.identity} unmuted.`);
});
conference.on('local-camera-video-added', function (event) {
    $('#localVideo').srcObject = event.stream;
});
conference.on('local-camera-video-removed', function (event) {
    $('#localVideo').srcObject = null;
});
conference.on('local-screenshare-added', function (event) {
    $('#localScreenShare').srcObject = event.stream;
});
conference.on('local-screenshare-removed', function (event) {
    $('#localScreenShare').srcObject = null;
});

The next four events are fired when another user adds or removes the video or starts or stops sharing screen. You should implement these event handlers in order to set and/or remove video stream as a source on corresponding HTML video elements.

conference.on('user-camera-video-added', function (event) {
    $('#remoteVideo-' + event.identity).srcObject = event.stream;
});
conference.on('user-camera-video-removed', function (event) {
    $('#remoteVideo-' + event.identity).srcObject = null;
});
conference.on('user-screenshare-added', function (event) {
    $('#remoteScreenShare-' + event.identity).srcObject = event.stream;
});
conference.on('user-screenshare-removed', function (event) {
    $('#remoteScreenShare-' + event.identity).srcObject = null;
});



muted()

Description

Returns information whether the audio is muted.

Arguments

  • none

Returns

  • boolean - true if audio is muted, otherwise false.

Example

let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let conference = infobipRTC.joinConference('conference-demo', ConferenceOptions.builder().audio(true).video(false).build());

conference.on('joined', function (event) {
    conference.mute(true);
    let muted = conference.muted() ? "muted" : "not muted";
    console.log(`Audio is ${muted}`);
});



hasCameraVideo()

Description

Returns information whether the user has local camera video.

Arguments

  • none

Returns

  • boolean - true if the user has local camera video, otherwise false.

Example

let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let conference = infobipRTC.joinConference('conference-demo', ConferenceOptions.builder().setAudio(true).build());

conference.on('joined', function (event) {
    conference.cameraVideo(true)
        .then(() => resolve())
        .catch(() => reject());
    let hasCameraVideo = conference.hasCameraVideo() ? "on" : "off";
    console.log(`Video is turned ${hasCameraVideo}.`);
});



hasScreenShare()

Description

Returns information whether the user is sharing the screen.

Arguments

  • none

Returns

  • boolean - true if screen is being share, otherwise false.

Example

let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let conference = infobipRTC.joinConference('conference-demo', ConferenceOptions.builder().audio(true).video(false).build());

conference.on('joined', function (event) {
    conference.screenShare(true)
        .then(() => resolve())
        .catch(() => reject());
    let hasScreenShare = conference.hasScreenShare() ? "shared." : "not shared.";
    console.log(`Screen is ${hasScreenShare}.`);
});



mute(shouldMute)

Description

Toggles mute option.

Arguments

  • shouldMute: boolean - Whether the audio should be muted after this action.

Returns

Example

let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let conference = infobipRTC.joinConference('conference-demo', ConferenceOptions.builder().audio(true).video(false).build());

conference.on('joined', function (event) {
    conference.mute(true)
        .then(() => resolve())
        .catch(() => reject());
});



cameraVideo(cameraVideo)

Description

Controls whether the local camera video should be enabled. For video calls it is enabled by default.

Arguments

  • cameraVideo: boolean
    • Whether local camera video should be enabled.

Returns

Example

let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let conference = infobipRTC.joinConference('conference-demo', ConferenceOptions.builder().setAudio(true).build());

conference.on('joined', function (event) {
    conference.cameraVideo(true)
        .then(() => resolve())
        .catch(() => reject());
});



screenShare(screenShare)

Description

Toggles sharing the screen during the conference.

Arguments

  • screenShare: boolean
    • Controls whether the screen sharing should be started or stopped.

Returns

Example

let infobipRTC = new InfobipRTC('2e29c3a0-730a-4526-93ce-cda44556dab5', {debug: true});
let conference = infobipRTC.joinConference('conference-demo', ConferenceOptions.builder().audio(true).video(false).build());

conference.on('joined', function (event) {
    conference.screenShare(true)
        .then(() => resolve())
        .catch(() => reject());
});



setAudioInputDevice(deviceId)

Description

Sets the audio input device with the given id to be used during the conference call.

Arguments

  • deviceId: string - Audio input device identifier.

Returns

Example

let conference = infobipRTC.joinConference('conference-demo', ConferenceOptions.builder().audio(true).video(false).build());
conference.on('joined', _ => {
    conference.setAudioInputDevice('audioDeviceId')
        .then(() => resolve())
        .catch(() => reject());
});



setVideoInputDevice(deviceId)

Description

Sets the video input device with the given id to be used during the conference call.

Arguments

  • deviceId: string - Video input device identifier.

Returns

Example

let conference = infobipRTC.joinConference('conference-demo', ConferenceOptions.builder().audio(true).video(true).build());
conference.on('joined', _ => {
    conference.setVideoInputDevice('videoDeviceId')
        .then(() => resolve())
        .catch(() => reject());
});



pauseIncomingVideo()

Description

Stop receiving the video media of other participants.

Arguments

  • none

Returns

  • none

Example

let conference = infobipRTC.joinConference('conference-demo', ConferenceOptions.builder().audio(true).video(true).build());
conference.on('joined', _ => {
    document.addEventListener("visibilitychange", () => {
        if (document.visibilityState !== 'visible') {
            console.log('Browser lost focus, stop showing remote video media.');
            activeConference.pauseIncomingVideo();
        }
    });
});



resumeIncomingVideo()

Description

Start receiving the video media of other participants.

Arguments

  • none

Returns

  • none

Example

let conference = infobipRTC.joinConference('conference-demo', ConferenceOptions.builder().audio(true).video(true).build());
conference.on('joined', _ => {
    document.addEventListener("visibilitychange", () => {
        if (document.visibilityState === 'visible') {
            console.log('Browser got focus back, start showing remote video media again.');
            activeConference.resumeIncomingVideo();
        }
    });
});
Clone this wiki locally