Skip to content

Playing the Stream

bapquad edited this page Feb 20, 2022 · 2 revisions

[Home] > Playing the Stream

This guide we will play the streaming.

Create stream viewer

First, you need to create the viewer in order to view the streaming. We should use the HTML tag with id is "main".

let stream = $.create("img#main");

Next, we start the streaming with the DOM element which we created above.

Start the streaming

We should use the StartStream method in the media5 package.

media5.StartStream(stream, "http://192.168.1.31:1080/mjpeg", 320, 280);

And now, full source look like as following.

import {element5 as $, media5} from '@bapquad/element5'

$.GetBody().css({
  "margin": 0, 
  "padding": 0
});

let stream = $.create("img#main");
media5.StartStream(stream, "http://192.168.1.31:1080/mjpeg", 320, 240);

$("#wrapper").add(stream);