create stream url in js

This commit is contained in:
2021-05-20 18:33:51 +02:00
parent f201d8e803
commit dd9be53140
2 changed files with 18 additions and 31 deletions

View File

@ -1,15 +1,14 @@
(() => {
const setRemotePlayer = () => {
class NewRemotePlayer extends cast.framework.RemotePlayer {
constructor() {
super();
this.canControlVolume = false;
}
}
cast.framework.RemotePlayer = NewRemotePlayer;
const findUpstream = () => {
const search = new URLSearchParams(location.search);
search.set("render", "false");
const url = new URL(location.origin);
url.pathname = location.pathname;
url.search = search.toString();
return url.href;
}
const upstream = "{{ stream }}";
const upstream = findUpstream();
const xhr = new XMLHttpRequest();
xhr.open("HEAD", upstream, true);
xhr.send();
@ -21,11 +20,6 @@
}
}
const handleLoaded = () => {
setRemotePlayer();
handleCount();
}
const handle = () => {
const [body] = document.getElementsByTagName("body");
const video = document.createElement("video");
@ -41,10 +35,6 @@
options.techOrder = ["chromecast", "html5"];
options.plugins = {};
options.plugins.chromecast = {};
options.plugins.chromecast.requestTitleFn = (src) => {
return "{% raw title %}";
}
const player = videojs(video, options);
const source = {};
source.type = ctype;
@ -66,7 +56,10 @@
player.one("play", () => {
player.removeChild(button);
});
player.on("chromecastConnected", () => {
player.volume(0.1);
});
}
document.addEventListener("DOMContentLoaded", handleLoaded);
document.addEventListener("DOMContentLoaded", handleCount);
xhr.addEventListener("load", handleCount);
})();