Skip to content

Instantly share code, notes, and snippets.

@recursivecodes
Created November 25, 2025 17:48
Show Gist options
  • Select an option

  • Save recursivecodes/9ba4c437c381b009d152b35e276856a6 to your computer and use it in GitHub Desktop.

Select an option

Save recursivecodes/9ba4c437c381b009d152b35e276856a6 to your computer and use it in GitHub Desktop.
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);
@recursivecodes
Copy link
Author

breakthrough-streaming.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment