add download support

This commit is contained in:
2022-02-13 14:15:33 +01:00
parent b667177531
commit 4267f6a7ca
3 changed files with 39 additions and 13 deletions

View File

@ -15,7 +15,7 @@
options.plugins.chromecast = {};
options.plugins.chromecast.addButtonToControlBar = false;
const player = videojs(video, options);
if((info.poster instanceof String) || ((typeof info.poster) == "string")) {
if(info.poster) {
player.poster(info.poster);
}
const source = {};
@ -24,8 +24,7 @@
player.src(source);
const dl = document.createElement("a");
dl.href = info.upstream;
dl.setAttribute("download", true);
dl.href = info.download;
const canPlayTypeRaw = player.canPlayType(info.ctype);
const canPlayType = (canPlayTypeRaw === "maybe") || (canPlayTypeRaw === "probably");
@ -66,7 +65,7 @@
bigCastButton.classList.add("vjs-big-chromecast");
player.addChild(bigCastButtonWrapper);
if(!info.ctype.toLowerCase().includes("mpegurl")) {
if(info.download) {
bigDownloadButton.classList.add("vjs-control");
bigDownloadButton.classList.add("vjs-button");
bigDownloadButton.classList.add("fas");
@ -77,7 +76,7 @@
player.one("error", () => {
player.removeChild(bigCastButtonWrapper);
if(!info.ctype.toLowerCase().includes("mpegurl")) {
if(info.download) {
player.removeChild(bigDownloadButtonWrapper);
}
});