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