Last active
April 13, 2021 11:28
-
-
Save cahva/1bbc4bd112b96262fb7a5d88cbe4b0b2 to your computer and use it in GitHub Desktop.
Daily.co embed own js
This file contains hidden or 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
<style> | |
#callframe { | |
height: 75vh; | |
min-height: 400px; | |
} | |
</style> | |
<script crossorigin src="https://unpkg.com/@daily-co/daily-js"></script> | |
<script> | |
const roomUrl = 'https://flik.daily.co/5lO7tNjTQFHJzwt0ZL4i'; | |
function tryEl(e) { | |
var privEl = document.querySelector('#vs-presentation'); | |
if (!privEl) { | |
window.requestAnimationFrame(tryEl); | |
} else { | |
changePlayer(privEl); | |
} | |
} | |
async function changePlayer(presentationEl) { | |
const mainwrapper = document.querySelector('.vs-mainwrapper'); | |
const callframeEl = document.createElement('div'); | |
callframeEl.id = 'callframe'; | |
mainwrapper.insertBefore(callframeEl, presentationEl.nextSibling) | |
presentationEl.remove(); | |
callFrame = window.DailyIframe.createFrame( | |
document.getElementById('callframe') | |
); | |
callFrame | |
.on('loaded', showEvent) | |
.on('started-camera', showEvent) | |
.on('camera-error', showEvent) | |
.on('joining-meeting', showEvent) | |
//.on('joined-meeting', showCallDisplay) | |
.on('recording-started', showEvent) | |
//.on('recording-stopped', resetRecordingButton) | |
.on('recording-stats', showEvent) | |
.on('recording-error', showEvent) | |
.on('app-message', showEvent) | |
.on('input-event', showEvent) | |
.on('error', showEvent) | |
// .on('participant-joined', updateParticipantInfoDisplay) | |
// .on('participant-updated', updateParticipantInfoDisplay) | |
// .on('participant-left', updateParticipantInfoDisplay) | |
// .on('left-meeting', hideCallDisplay); | |
.on('left-meeting', showEvent); | |
joinCall(); | |
} | |
function onLoaded() { | |
joinCall(); | |
} | |
async function joinCall() { | |
const userName = _authData && _authData.name ? _authData.name : null; | |
await callFrame.join({ | |
url: roomUrl, | |
showLeaveButton: false, | |
userName | |
}); | |
} | |
function showEvent(e) { | |
console.log('callFrame event', e); | |
} | |
tryEl(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment