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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

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

View File

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