From e6618bd432389c5af3ba8f79809bc996d87dcfa5 Mon Sep 17 00:00:00 2001 From: Jerry Date: Sat, 15 Apr 2023 20:00:36 +0800 Subject: [PATCH] update --- app/cyp.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/app/cyp.js b/app/cyp.js index 2ecf006..65001ec 100644 --- a/app/cyp.js +++ b/app/cyp.js @@ -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 = ""; + 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);