Skip to content

Instantly share code, notes, and snippets.

@tab1293
Created February 5, 2021 17:16
Show Gist options
  • Save tab1293/ed3b69c48d9f54c02d69cbbf268e5a4b to your computer and use it in GitHub Desktop.
Save tab1293/ed3b69c48d9f54c02d69cbbf268e5a4b to your computer and use it in GitHub Desktop.
ION SFU example
<html>
<head>
<script src="/ion.min.js"></script>
<script src="/json-rpc.min.js"></script>
</head>
<body>
<video id="video" src="test.mp4" width="1280px" height="720px" controls />
</body>
<script>
const v = document.getElementById("video");
const signal = new Signal.IonSFUJSONRPCSignal("wss://localhost:7000/ws");
const client = new IonSDK.Client(signal);
signal.onopen = async () => {
client.join("test session");
// const captureStream = v.captureStream();
// const localStream = new IonSDK.LocalStream(captureStream, {
// resolution: "hd",
// codec: "h264",
// audio: true,
// video: true,
// simulcast: false,
// });
const localStream = await IonSDK.LocalStream.getUserMedia();
client.publish(localStream);
};
</script>
</html>
<html>
<head>
<script src="/ion.min.js"></script>
<script src="/json-rpc.min.js"></script>
</head>
<body>
<video id="video" width="1280px" height="720px" controls />
</body>
<script>
const v = document.getElementById("video");
let mediaStream = new MediaStream();
v.srcObject = mediaStream
const signal = new Signal.IonSFUJSONRPCSignal("wss://localhost:7000/ws");
const client = new IonSDK.Client(signal);
signal.onopen = () => {
client.join("test session");
};
client.ontrack = (track, stream) => {
mediaStream.addTrack(track);
};
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment