add chromecast conditionally

This commit is contained in:
Roy Olav Purser 2021-05-21 13:41:34 +02:00
parent b4d7b81a66
commit 45d9841743
Signed by: roypur
GPG Key ID: E14D26A036F21656
2 changed files with 17 additions and 2 deletions

View File

@ -54,16 +54,16 @@
bigCastButton.addClass("vjs-control");
bigCastButton.addClass("vjs-button");
bigCastButton.addClass("vjs-big-chromecast");
player.addChild(bigCastButton);
const smallCastButton = new Button(player, cbutton);
smallCastButton.addClass("fab");
smallCastButton.addClass("fa-chromecast");
smallCastButton.addClass("vjs-control");
smallCastButton.addClass("vjs-button");
player.controlBar.addChild(smallCastButton);
let loadScreen = true;
player.one("play", () => {
loadScreen = false;
player.removeChild(bigCastButton);
});
@ -73,6 +73,18 @@
player.volume(0.2);
}
});
player.on("chromecastDevicesAvailable", () => {
player.controlBar.addChild(smallCastButton);
if(loadScreen) {
player.addChild(bigCastButton);
}
});
player.on("chromecastDevicesUnvailable", () => {
player.controlBar.removeChild(smallCastButton);
if(loadScreen) {
player.removeChild(bigCastButton);
}
});
}
document.addEventListener("DOMContentLoaded", handleCount);
xhr.addEventListener("load", handleCount);

View File

@ -4,6 +4,9 @@ body {
.fa-chromecast:before {
font-size: 1.2em;
}
.vjs-button {
cursor:pointer;
}
.vjs-big-chromecast {
position: absolute !important;
font-size: 3rem !important;