Skip to content

Instantly share code, notes, and snippets.

@tomtobac
Last active August 29, 2022 10:21
Show Gist options
  • Save tomtobac/82379fd6a9f75dbdb815d0add101f3a0 to your computer and use it in GitHub Desktop.
Save tomtobac/82379fd6a9f75dbdb815d0add101f3a0 to your computer and use it in GitHub Desktop.
Publish and play a video in video-composer
// 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