<video id="localVideo" autoplay controls width=480px height=360px></video>
<br/>
<button id="publish_start">Start Publishing</button>
<button id="publish_stop">Stop Publishing</button>
<br/>
<p id="status_info">Offline</p>
import {WebRTCAdaptor} from "https://cdn.skypack.dev/@antmedia/webrtc_adaptor";
var webRTCAdaptor = new WebRTCAdaptor({
websocket_url: "wss://test.antmedia.io:5443/WebRTCAppEE/websocket",
localVideoElement: document.getElementById("localVideo"),
callback: (info, obj) => {
console.log("callback info: " + info);
if (info == "publish_started") {
console.log("publish started");
statusInfo.innerHTML = "Broadcasting - Stream Id: " + streamId;
}
else if (info == "publish_finished") {
console.log("publish finished")
statusInfo.innerHTML = "Offline"
}
},
});
var streamId = "stream" + parseInt(Math.random()*999999);
var statusInfo = document.getElementById("status_info");
document.getElementById("publish_start").addEventListener("click",()=> {
webRTCAdaptor.publish(streamId)
})
document.getElementById("publish_stop").addEventListener("click",()=> {
webRTCAdaptor.stop(streamId)
})
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.