Last active
November 6, 2019 13:56
-
-
Save sanatem/98fa7f47abe42ed09260a2d95032d128 to your computer and use it in GitHub Desktop.
Webex meetings Event listeners
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bindMeetingEvents(meeting) { | |
meeting.on('error', (err) => { | |
console.error(err); | |
}); | |
// Handle media streams changes to ready state | |
meeting.on('media:ready', (media) => { | |
if (!media) { | |
return; | |
} | |
if (media.type === 'local') { | |
document.getElementById('self-view').srcObject = media.stream; | |
} | |
if (media.type === 'remoteVideo') { | |
document.getElementById('remote-view-video').srcObject = media.stream; | |
} | |
if (media.type === 'remoteAudio') { | |
document.getElementById('remote-view-audio').srcObject = media.stream; | |
} | |
}); | |
// Handle media streams stopping | |
meeting.on('media:stopped', (media) => { | |
// Remove media streams | |
if (media.type === 'local') { | |
document.getElementById('self-view').srcObject = null; | |
} | |
if (media.type === 'remoteVideo') { | |
document.getElementById('remote-view-video').srcObject = null; | |
} | |
if (media.type === 'remoteAudio') { | |
document.getElementById('remote-view-audio').srcObject = null; | |
} | |
}); | |
// Of course, we'd also like to be able to leave the meeting: | |
document.getElementById('hangup').addEventListener('click', () => { | |
meeting.leave(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment