Created
February 5, 2021 17:16
-
-
Save tab1293/ed3b69c48d9f54c02d69cbbf268e5a4b to your computer and use it in GitHub Desktop.
ION SFU example
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
<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> |
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
<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