add download as link
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
Roy Olav Purser 2022-03-13 09:53:25 +01:00
parent b1a2a7cfc8
commit 5c77554df0
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -27,32 +27,19 @@
const canPlayType = (canPlayTypeRaw === "maybe") || (canPlayTypeRaw === "probably"); const canPlayType = (canPlayTypeRaw === "maybe") || (canPlayTypeRaw === "probably");
if(canPlayType) { if(canPlayType) {
const Button = videojs.getComponent("Button"); const Button = videojs.getComponent("Button");
const Component = videojs.getComponent("Component");
const cbutton = {}; const cbutton = {};
cbutton.clickHandler = (ev) => { cbutton.clickHandler = (ev) => {
player.trigger("chromecastRequested"); 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 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 bigCastButton = bigCastButtonWrapper.el();
const bigDownloadButton = bigDownloadButtonWrapper.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-control");
bigCastButton.classList.add("vjs-button"); bigCastButton.classList.add("vjs-button");
@ -62,6 +49,7 @@
player.addChild(bigCastButtonWrapper); player.addChild(bigCastButtonWrapper);
if(info.download) { if(info.download) {
bigDownloadButton.href = info.download;
bigDownloadButton.classList.add("vjs-control"); bigDownloadButton.classList.add("vjs-control");
bigDownloadButton.classList.add("vjs-button"); bigDownloadButton.classList.add("vjs-button");
bigDownloadButton.classList.add("fas"); bigDownloadButton.classList.add("fas");