deepch / RTSPtoWeb

RTSP Stream to WebBrowser
MIT License
1.17k stars 284 forks source link

Force RTC in multiview #391

Open vedranius opened 8 months ago

vedranius commented 8 months ago

Hi, is it possible to force RTC in multiview, so that I don't have to manually select it every time I open the page? Tnx!

HurtZMH commented 8 months ago

Sure! But I would recommend you develop your own interface as web in project is just an example!

Anyway, in multiview.tmpl -> /web/template/multiview.tmpl, you should look for play function, to understand why, just see the function:

function play(uuid, index, chan, typePlayer) { //a lot of code ... }

The typePlayer var keeps exactly what you want, to minimize changes and save some time, you just need to overwrite the variable with one you want to use, like 'mse', 'webrtc', or 'hls', note there's no hlsll in multiview.

This is not the best solution, but will work for you without a lot of codding.

function play(uuid, index, chan, typePlayer) { typePlayer = 'webrtc'; //rest of code ... }

Keep in mind, in this case, it will not hidden the defaultPlayer selection and it will not allow changing protocol in this select nevermore, ok?

To hide button, just comment or delete lines 43 to 47 in same file (multiview.tmpl).

But if you want to keep this working and just want to put webrtc as a default player, just change line 39:

<input type="hidden" id="defaultPlayer" value="mse" />

for

<input type="hidden" id="defaultPlayer" value="webrtc" />

There's only one detail, as you store it in localstorage, even if default player is set to webrtc in this case, if early you played the video was in mse, this will restore using the mse one, so you need to select the stream again to change protocol and store it in localstorage.

OR

you can set the defaultPlayer input to 'webrtc' and disable the select button, it can hypothetically run on other protocols, but as you don't let the selection change via the button that is now hidden, it should always run on the protocol you define in the input.

See? There's a lot of ways to do that, but as I said, I strongly recommend you to develop your own interface!

Right? Hope it can help!