check content type before adding chromecast
This commit is contained in:
parent
82f8e6ea40
commit
358693035b
@ -41,46 +41,44 @@
|
||||
source.type = ctype;
|
||||
source.src = upstream;
|
||||
player.src(source);
|
||||
const Button = videojs.getComponent("Button");
|
||||
const cbutton = {};
|
||||
cbutton.clickHandler = (ev) => {
|
||||
player.trigger("chromecastRequested");
|
||||
}
|
||||
cbutton.text = "Chromecast";
|
||||
|
||||
const bigCastButton = new Button(player, cbutton);
|
||||
bigCastButton.addClass("fab");
|
||||
bigCastButton.addClass("fa-chromecast");
|
||||
bigCastButton.addClass("vjs-control");
|
||||
bigCastButton.addClass("vjs-button");
|
||||
bigCastButton.addClass("vjs-big-chromecast");
|
||||
|
||||
player.one("canplay", () => {
|
||||
player.addChild(bigCastButton);
|
||||
});
|
||||
|
||||
player.on("loadedmetadata", () => {
|
||||
console.log("loadedmetadata");
|
||||
});
|
||||
|
||||
player.on("posterchange", () => {
|
||||
console.log("posterchange");
|
||||
});
|
||||
|
||||
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);
|
||||
player.one("play", () => {
|
||||
player.removeChild(bigCastButton);
|
||||
});
|
||||
player.on("chromecastConnected", () => {
|
||||
if(player.volume() > 0.3) {
|
||||
player.volume(0.2);
|
||||
const canPlayTypeRaw = player.canPlayType(ctype);
|
||||
const canPlayType = (canPlayTypeRaw === "maybe") || (canPlayTypeRaw === "probably");
|
||||
if(canPlayType) {
|
||||
const Button = videojs.getComponent("Button");
|
||||
const cbutton = {};
|
||||
cbutton.clickHandler = (ev) => {
|
||||
player.trigger("chromecastRequested");
|
||||
}
|
||||
});
|
||||
cbutton.text = "Chromecast";
|
||||
|
||||
const bigCastButton = new Button(player, cbutton);
|
||||
bigCastButton.addClass("fab");
|
||||
bigCastButton.addClass("fa-chromecast");
|
||||
bigCastButton.addClass("vjs-control");
|
||||
bigCastButton.addClass("vjs-button");
|
||||
bigCastButton.addClass("vjs-big-chromecast");
|
||||
player.addChild(bigCastButton);
|
||||
|
||||
player.one("error", () => {
|
||||
player.removeChild(bigCastButton);
|
||||
});
|
||||
|
||||
player.one("play", () => {
|
||||
player.removeChild(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);
|
||||
player.on("chromecastConnected", () => {
|
||||
if(player.volume() > 0.3) {
|
||||
player.volume(0.2);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
document.addEventListener("DOMContentLoaded", handleCount);
|
||||
xhr.addEventListener("load", handleCount);
|
||||
|
Loading…
Reference in New Issue
Block a user