Improving showing/hiding of chromecastbutton

This commit is contained in:
Kasper Rynning-Tønnesen
2017-01-24 12:15:53 +01:00
parent e515915ec8
commit 9d21e059f7
4 changed files with 14 additions and 10 deletions

View File

@@ -263,7 +263,7 @@ var Frontpage = {
window.history.pushState("to the channel!", "Title", "/" + new_channel);
window.chan = new_channel;
}
console.log(chromecastReady);
var response = $("<div>" + e + "</div>");
$(".mega").remove();
@@ -384,7 +384,6 @@ function initfp(){
if (loaded) {
chromecastReady = true;
} else {
console.log(errorInfo);
}
}
}

View File

@@ -243,23 +243,24 @@ function init(){
$("#search").attr("placeholder", "Find song on YouTube...");
if(chromecastAvailable){
//hide_native(1);
hide_native(1);
} else if(chromecastReady) {
initializeCastApi();
} else {
window['__onGCastApiAvailable'] = function(loaded, errorInfo) {
if (loaded) {
setTimeout(function(){
chromecastReady = true;
initializeCastApi();
}, 1000);
} else {
chromecastReady = true;
}
}
}
}
initializeCastApi = function() {
$(".castButton").css("display", "block");
cast.framework.CastContext.getInstance().setOptions({
receiverApplicationId: "E6856E24",
autoJoinPolicy: chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED});
@@ -312,6 +313,10 @@ initializeCastApi = function() {
break;
}
});
Helper.log(cast.framework.CastContext.getInstance().getCastState());
if(cast.framework.CastContext.getInstance().getCastState() == "NO_DEVICES_AVAILABLE"){
$(".castButton").css("display", "none");
}
};
function hide_native(way){