Created
November 25, 2025 17:48
-
-
Save recursivecodes/9ba4c437c381b009d152b35e276856a6 to your computer and use it in GitHub Desktop.
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
| const script = document.createElement('script'); | |
| script.src = 'https://web-broadcast.live-video.net/1.30.0/amazon-ivs-web-broadcast.js'; | |
| script.onload = async () => { | |
| const token = prompt('Enter your IVS Real-Time participant token:'); | |
| if (!token) { | |
| console.error('No token provided'); | |
| return; | |
| } | |
| const canvas = document.getElementById('gameCanvas'); | |
| const stream = canvas.captureStream(30); | |
| const videoTrack = stream.getVideoTracks()[0]; | |
| const canvasStream = new IVSBroadcastClient.LocalStageStream(videoTrack); | |
| const strategy = { | |
| stageStreamsToPublish() { | |
| return [canvasStream]; | |
| }, | |
| shouldPublishParticipant() { | |
| return true; | |
| }, | |
| shouldSubscribeToParticipant() { | |
| return IVSBroadcastClient.SubscribeType.NONE; | |
| } | |
| }; | |
| const stage = new IVSBroadcastClient.Stage(token, strategy); | |
| stage.on(IVSBroadcastClient.StageEvents.STAGE_CONNECTION_STATE_CHANGED, (state) => { | |
| console.log('Stage connection state:', state); | |
| }); | |
| await stage.join(); | |
| console.log('Streaming canvas to IVS Real-Time stage'); | |
| }; | |
| document.head.appendChild(script); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
breakthrough-streaming.mp4