diff --git a/frontend/script.js b/frontend/script.js index d0d52fc..e6e1cdf 100644 --- a/frontend/script.js +++ b/frontend/script.js @@ -27,32 +27,19 @@ const canPlayType = (canPlayTypeRaw === "maybe") || (canPlayTypeRaw === "probably"); if(canPlayType) { const Button = videojs.getComponent("Button"); + const Component = videojs.getComponent("Component"); + const cbutton = {}; cbutton.clickHandler = (ev) => { player.trigger("chromecastRequested"); } - cbutton.text = "Chromecast"; - - const dbutton = {}; - 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); + const bigDownloadButtonWrapper = new Component(player); + bigDownloadButtonWrapper.el_ = document.createElement("a"); const bigCastButton = bigCastButtonWrapper.el(); const bigDownloadButton = bigDownloadButtonWrapper.el(); - for(const elem of bigCastButton.children) { - bigCastButton.removeChild(elem); - } - - for(const elem of bigDownloadButton.children) { - bigDownloadButton.removeChild(elem); - } bigCastButton.classList.add("vjs-control"); bigCastButton.classList.add("vjs-button"); @@ -62,6 +49,7 @@ player.addChild(bigCastButtonWrapper); if(info.download) { + bigDownloadButton.href = info.download; bigDownloadButton.classList.add("vjs-control"); bigDownloadButton.classList.add("vjs-button"); bigDownloadButton.classList.add("fas");