Last active
August 29, 2022 10:21
-
-
Save tomtobac/82379fd6a9f75dbdb815d0add101f3a0 to your computer and use it in GitHub Desktop.
Publish and play a video in video-composer
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
// Get video url from context which has been passed by ExtensionEnvironment when we create a MediaProcessor | |
const videoUrl = window.context.ENV_videoUrl; | |
const videoClip = document.getElementById('video'); // Your video element <video id="video"></video> | |
videoClip.src = videoUrl; | |
videoClip.load(); | |
const stream = video.captureStream(); | |
const videoClipStream = stream.getVideoTracks()[0]; | |
videoClip.play(); | |
// Create a new LocalVideoTrack | |
const videoTrack = new Video.LocalVideoTrack(videoClipStream, { | |
name: "video-composer-presentation", | |
}); | |
// Publish the LocalVideoTrack to the Room | |
room.localParticipant.publishTrack(videoTrack) | |
.then(() => { console.log('Published video track'); }); | |
videoClip.addEventListener( | |
'ended', | |
() => { | |
/* | |
* Video has finished so we can remove it. | |
* E.g.: video.remove() | |
*/ | |
}, | |
false | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment