Publishing a stream using custom HTML5 video element¶
By default, WebSDK creates HTML5 video element automatically to display a stream captured. However, in some cases it is necessary to display a stream on custom video element. This can be done as follows:
-
Add
video
element to example HTML page -
Create a container to set
srcObject
on stream creation -
Copy
srcObject
from the container to customvideo
elementvar video = document.getElementById("customVideo"); stream = session.createStream({ name: $('#streamName').val(), display: mockLocalDisplay.get(0) }).on(STREAM_STATUS.PUBLISHING, function (stream) { var srcObject = mockLocalVideo.get(0).srcObject; video.srcObject = srcObject; mockLocalVideo.get(0).pause(); mockLocalVideo.get(0).srcObject = null; }); stream.publish();