This commit is contained in:
JerryXiao 2023-04-15 20:00:36 +08:00
parent edbc474b9a
commit e6618bd432
Signed by: Jerry
GPG key ID: 22618F758B5BE2E5

View file

@ -664,11 +664,41 @@ class App extends HTMLElement {
}
let btnlive = document.createElement("button");
btnlive.innerText = "Back to live";
btnlive.style = "margin-right: 10px;"
btnlive.onclick = function() {
if (audio) { audio.load(); audio.play(); }
}
let btnvid = document.createElement("button");
btnvid.innerText = "Show video";
btnvid.onclick = function() {
let hostname = document.location.hostname;
let hostsuffix = "jerry.dn42";
if (hostname.endsWith("jerry.neo")) { hostsuffix = "jerry.neo" }
else if (hostname.endsWith("meson.cc")) { hostsuffix = "meson.cc" }
if (audio) { btnkill.onclick(); }
let i;
i = document.createElement("style");
i.innerText = ".vjs-error,.vjs-error-display,.vjs-modal-dialog-content,.vjs-control-bar{font-size:120%}";
document.head.appendChild(i);
i = document.createElement("link");
i.href = `//live.${hostsuffix}/ajax/libs/video.js/7.10.2/video-js.min.css`;
i.rel = "stylesheet";
document.head.appendChild(i);
i = document.createElement("script");
let vjs = i;
i.src = `//live.${hostsuffix}/ajax/libs/video.js/7.10.2/video.min.js`;
document.head.appendChild(i);
let d2 = document.createElement("div");
d2.innerHTML = "<video-js id=\"vid1\" class=\"vjs-fluid vjs-big-play-centered\" controls><source src=\"//stream."+hostsuffix+"/m.m3u8\" type=\"application/x-mpegURL\"/></video-js>";
root.insertAdjacentElement('afterbegin', d2);
i = document.createElement("script");
i.innerText = "videojs(\"vid1\", {html5: {vhs: {withCredentials: true}}})";
vjs.onload = () => {document.head.appendChild(i)};
btnvid.hidden = true;
}
divbutton.appendChild(btnkill);
divbutton.appendChild(btnlive);
divbutton.appendChild(btnvid);
d1.appendChild(divbutton);
d1.appendChild(divaudio);
root.appendChild(d1);