feat(html): update webrtc page (#3361)

optimized webrtc page
This commit is contained in:
johzzy 2024-03-12 23:48:17 -03:00 committed by GitHub
parent 1e39594335
commit 69800632fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -115,17 +115,10 @@
document.getElementsByName("method").forEach((el,idx) => {
el.checked = el.value === type;
el.onclick = function(e) {
let url = new URL(document.getElementById('streamUrl').value);
const url = new URL(document.getElementById('streamUrl').value);
url.searchParams.set("type",el.value);
document.getElementById('streamUrl').value = url.toString();
if(el.value == "play"){
recvOnly = true;
}else if(el.value == "echo"){
recvOnly = false;
}else{
recvOnly = false;
}
recvOnly = 'play' === el.value;
};
});
@ -145,6 +138,25 @@
let h = parseInt(res.pop());
let w = parseInt(res.pop());
const url = new URL(document.getElementById('streamUrl').value);
const newUrl = new URL(window.location.href);
let count = 0;
if (url.searchParams.has('app')) {
newUrl.searchParams.set('app', url.searchParams.get('app'));
count++;
}
if (url.searchParams.has('stream')) {
newUrl.searchParams.set('stream', url.searchParams.get('stream'));
count++;
}
if (url.searchParams.has('type')) {
newUrl.searchParams.set('type', url.searchParams.get('type'));
count++;
}
if (count > 0) {
window.history.pushState(null, null, newUrl);
}
player = new ZLMRTCClient.Endpoint(
{
element: document.getElementById('video'),// video 标签