Remove support for browsers not supporting TextDecoder to fix eslint

pull/3750/head
Isaac Connor 2023-08-08 13:01:42 -04:00
parent b97c189941
commit 1e200abf16
1 changed files with 25 additions and 20 deletions

View File

@ -209,20 +209,29 @@ function MonitorStream(monitorData) {
return; return;
} else if (this.RTSP2WebEnabled) { } else if (this.RTSP2WebEnabled) {
videoEl = document.getElementById("liveStream" + this.id); videoEl = document.getElementById("liveStream" + this.id);
useSSL = ZM_RTSP2WEB_PATH.startsWith('https'); const url = new URL(ZM_RTSP2WEB_PATH);
rtsp2webModUrl = ZM_RTSP2WEB_PATH.split('@')[1]; // drop the username and password for viewing const useSSL = (url.protocol == 'https');
if (this.RTSP2WebType == "HLS") {
rtsp2webModUrl = url;
rtsp2webModUrl.username='';
rtsp2webModUrl.password='';
//.urlParts.length > 1 ? urlParts[1] : urlParts[0]; // drop the username and password for viewing
if (this.RTSP2WebType == 'HLS') {
hlsUrl = rtsp2webModUrl;
hlsUrl.pathname = "/stream/" + this.id + "/channel/0/hls/live/index.m3u8";
/*
if (useSSL) { if (useSSL) {
hlsUrl = "https://" + rtsp2webModUrl + "/stream/" + this.id + "/channel/0/hls/live/index.m3u8"; hlsUrl = "https://" + rtsp2webModUrl + "/stream/" + this.id + "/channel/0/hls/live/index.m3u8";
} else { } else {
hlsUrl = "http://" + rtsp2webModUrl + "/stream/" + this.id + "/channel/0/hls/live/index.m3u8"; hlsUrl = "http://" + rtsp2webModUrl + "/stream/" + this.id + "/channel/0/hls/live/index.m3u8";
} }
*/
if (Hls.isSupported()) { if (Hls.isSupported()) {
const hls = new Hls(); const hls = new Hls();
hls.loadSource(hlsUrl); hls.loadSource(hlsUrl.href);
hls.attachMedia(videoEl); hls.attachMedia(videoEl);
} else if (video.canPlayType('application/vnd.apple.mpegurl')) { } else if (video.canPlayType('application/vnd.apple.mpegurl')) {
videoEl.src = hlsUrl; videoEl.src = hlsUrl.href;
} }
} else if (this.RTSP2WebType == "MSE") { } else if (this.RTSP2WebType == "MSE") {
videoEl.addEventListener('pause', () => { videoEl.addEventListener('pause', () => {
@ -231,20 +240,16 @@ function MonitorStream(monitorData) {
videoEl.play(); videoEl.play();
} }
}); });
if (useSSL) { mseUrl = rtsp2webModUrl;
mseUrl = "wss://" + rtsp2webModUrl + "/stream/" + this.id + "/channel/0/mse?uuid=" + this.id + "&channel=0"; mseUrl.protocol = useSSL ? 'wss' : 'ws';
} else { mseUrl.pathname = "/stream/" + this.id + "/channel/0/mse?uuid=" + this.id + "&channel=0";
mseUrl = "ws://" + rtsp2webModUrl + "/stream/" + this.id + "/channel/0/mse?uuid=" + this.id + "&channel=0"; console.log(mseUrl.href);
} startMsePlay(this, videoEl, mseUrl.href);
startMsePlay(this, videoEl, mseUrl); } else if (this.RTSP2WebType == 'WebRTC') {
} else if (this.RTSP2WebType == "WebRTC") { webrtcUrl = rtsp2webModUrl;
if (useSSL) { webrtcUrl.pathname = "/stream/" + this.id + "/channel/0/webrtc";
webrtcUrl = "https://" + rtsp2webModUrl + "/stream/" + this.id + "/channel/0/webrtc"; console.log(webrtcUrl.href);
} else { startRTSP2WebRTSPPlay(videoEl, webrtcUrl.href);
webrtcUrl = "http://" + rtsp2webModUrl + "/stream/" + this.id + "/channel/0/webrtc";
}
console.log(webrtcUrl);
startRTSP2WebRTSPPlay(videoEl, webrtcUrl);
} }
} else { } else {
// zms stream // zms stream
@ -928,7 +933,7 @@ function startMsePlay(context, videoEl, url) {
if (window.TextDecoder) { if (window.TextDecoder) {
mimeCodec = new TextDecoder('utf-8').decode(decodedArr); mimeCodec = new TextDecoder('utf-8').decode(decodedArr);
} else { } else {
mimeCodec = Utf8ArrayToStr(decodedArr); console.log("Browser too old. Doesn't support TextDecoder");
} }
context.mseSourceBuffer = mse.addSourceBuffer('video/mp4; codecs="' + mimeCodec + '"'); context.mseSourceBuffer = mse.addSourceBuffer('video/mp4; codecs="' + mimeCodec + '"');
context.mseSourceBuffer.mode = 'segments'; context.mseSourceBuffer.mode = 'segments';