1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

update cast icon visibility

This commit is contained in:
Luke Pulverenti 2014-02-23 12:53:25 -05:00
parent 869717c745
commit fd80cb3da5

View file

@ -1,7 +1,7 @@
(function (window, chrome, console) { (function (window, chrome, console) {
// Based on https://github.com/googlecast/CastVideos-chrome/blob/master/CastVideos.js // Based on https://github.com/googlecast/CastVideos-chrome/blob/master/CastVideos.js
/** /**
* Constants of states for Chromecast device * Constants of states for Chromecast device
**/ **/
@ -85,7 +85,7 @@
if (!chrome) { if (!chrome) {
return; return;
} }
if (!chrome.cast || !chrome.cast.isAvailable) { if (!chrome.cast || !chrome.cast.isAvailable) {
setTimeout(this.initializeCastPlayer.bind(this), 1000); setTimeout(this.initializeCastPlayer.bind(this), 1000);
return; return;
@ -100,7 +100,7 @@
this.receiverListener.bind(this)); this.receiverListener.bind(this));
console.log('chrome.cast.initialize'); console.log('chrome.cast.initialize');
chrome.cast.initialize(apiConfig, this.onInitSuccess.bind(this), this.onError.bind(this)); chrome.cast.initialize(apiConfig, this.onInitSuccess.bind(this), this.onError.bind(this));
}; };
@ -109,7 +109,6 @@
*/ */
CastPlayer.prototype.onInitSuccess = function () { CastPlayer.prototype.onInitSuccess = function () {
console.log("init success"); console.log("init success");
$('.btnCast').show();
this.updateMediaControlUI(); this.updateMediaControlUI();
}; };
@ -128,7 +127,7 @@
* join existing session and occur in Cast mode and media * join existing session and occur in Cast mode and media
* status gets synced up with current media of the session * status gets synced up with current media of the session
*/ */
CastPlayer.prototype.sessionListener = function(e) { CastPlayer.prototype.sessionListener = function (e) {
this.session = e; this.session = e;
if (this.session) { if (this.session) {
this.deviceState = DEVICE_STATE.ACTIVE; this.deviceState = DEVICE_STATE.ACTIVE;
@ -318,7 +317,14 @@
/** /**
* Update media control UI components based on localPlayerState or castPlayerState * Update media control UI components based on localPlayerState or castPlayerState
*/ */
CastPlayer.prototype.updateMediaControlUI = function() { CastPlayer.prototype.updateMediaControlUI = function () {
if (!chrome || !chrome.cast) {
$('.btnCast').hide();
return;
}
$('.btnCast').show();
if (this.deviceState == DEVICE_STATE.ACTIVE) { if (this.deviceState == DEVICE_STATE.ACTIVE) {
$('.btnCast').removeClass('btnDefaultCast').addClass('btnActiveCast'); $('.btnCast').removeClass('btnDefaultCast').addClass('btnActiveCast');
var playerState = this.castPlayerState; var playerState = this.castPlayerState;
@ -328,29 +334,33 @@
} }
switch (playerState) { switch (playerState) {
case PLAYER_STATE.LOADED: case PLAYER_STATE.LOADED:
case PLAYER_STATE.PLAYING: case PLAYER_STATE.PLAYING:
//document.getElementById("play").style.display = 'none'; //document.getElementById("play").style.display = 'none';
//document.getElementById("pause").style.display = 'block'; //document.getElementById("pause").style.display = 'block';
break; break;
case PLAYER_STATE.PAUSED: case PLAYER_STATE.PAUSED:
case PLAYER_STATE.IDLE: case PLAYER_STATE.IDLE:
case PLAYER_STATE.LOADING: case PLAYER_STATE.LOADING:
case PLAYER_STATE.STOPPED: case PLAYER_STATE.STOPPED:
//document.getElementById("play").style.display = 'block'; //document.getElementById("play").style.display = 'block';
//document.getElementById("pause").style.display = 'none'; //document.getElementById("pause").style.display = 'none';
break; break;
default: default:
break; break;
} }
}; };
window.CastPlayer = CastPlayer; window.CastPlayer = CastPlayer;
$(function() { $(function () {
var castPlayer = new CastPlayer(); var castPlayer = new CastPlayer();
$(document).on('pagebeforeshow', ".libraryPage", function () {
castPlayer.updateMediaControlUI();
});
}); });
})(window, window.chrome, console); })(window, window.chrome, console);