diff --git a/frontend/script.js b/frontend/script.js index 6716c90..d0d52fc 100644 --- a/frontend/script.js +++ b/frontend/script.js @@ -23,9 +23,6 @@ source.src = info.upstream; player.src(source); - const dl = document.createElement("a"); - dl.href = info.download; - const canPlayTypeRaw = player.canPlayType(info.ctype); const canPlayType = (canPlayTypeRaw === "maybe") || (canPlayTypeRaw === "probably"); if(canPlayType) { @@ -37,13 +34,12 @@ cbutton.text = "Chromecast"; const dbutton = {}; - dbutton.clickHandler = (ev) => { - document.body.appendChild(dl); - dl.click(); - document.body.removeChild(dl); - } - dbutton.text = "Download"; + dbutton.clickHandler = (ev) => { + if(info.download) { + window.open(info.download); + } + } const bigCastButtonWrapper = new Button(player, cbutton); const bigDownloadButtonWrapper = new Button(player, dbutton); @@ -83,7 +79,7 @@ player.one("play", () => { player.removeChild(bigCastButtonWrapper); - if(!info.ctype.toLowerCase().includes("mpegurl")) { + if(info.download) { player.removeChild(bigDownloadButtonWrapper); } });