mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Cast updates
This commit is contained in:
parent
e9b554b932
commit
84eb555644
4 changed files with 57 additions and 5 deletions
|
@ -76,6 +76,13 @@
|
|||
this.initializeCastPlayer();
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize local media player
|
||||
*/
|
||||
CastPlayer.prototype.initializeLocalPlayer = function () {
|
||||
this.localPlayer = document.getElementById('itemVideo');
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize Cast media player
|
||||
* Initializes the API. Note that either successCallback and errorCallback will be
|
||||
|
@ -89,6 +96,7 @@
|
|||
}
|
||||
|
||||
if (!chrome.cast || !chrome.cast.isAvailable) {
|
||||
|
||||
setTimeout(this.initializeCastPlayer.bind(this), 1000);
|
||||
return;
|
||||
}
|
||||
|
@ -136,6 +144,7 @@
|
|||
if (this.session.media[0]) {
|
||||
this.onMediaDiscovered('activeSession', this.session.media[0]);
|
||||
}
|
||||
this.session.addUpdateListener(this.sessionUpdateListener.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -145,9 +154,13 @@
|
|||
* does not provide a list of device IDs
|
||||
*/
|
||||
CastPlayer.prototype.receiverListener = function (e) {
|
||||
|
||||
console.log("cast.receiverListener", e);
|
||||
|
||||
if (e === 'available') {
|
||||
console.log("chromecast receiver found");
|
||||
this.hasReceivers = true;
|
||||
this.updateMediaControlUI();
|
||||
}
|
||||
else {
|
||||
console.log("chromecast receiver list empty");
|
||||
|
@ -155,6 +168,25 @@
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* session update listener
|
||||
*/
|
||||
CastPlayer.prototype.sessionUpdateListener = function (isAlive) {
|
||||
if (!isAlive) {
|
||||
this.session = null;
|
||||
this.deviceState = DEVICE_STATE.IDLE;
|
||||
this.castPlayerState = PLAYER_STATE.IDLE;
|
||||
this.currentMediaSession = null;
|
||||
clearInterval(this.timer);
|
||||
this.updateDisplayMessage();
|
||||
|
||||
//// continue to play media locally
|
||||
//console.log("current time: " + this.currentMediaTime);
|
||||
//this.playMediaLocally(this.currentMediaTime);
|
||||
this.updateMediaControlUI();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Requests that a receiver application session be created or joined. By default, the SessionRequest
|
||||
* passed to the API at initialization time is used; this may be overridden by passing a different
|
||||
|
@ -177,6 +209,7 @@
|
|||
this.session = e;
|
||||
this.deviceState = DEVICE_STATE.ACTIVE;
|
||||
this.updateMediaControlUI();
|
||||
this.session.addUpdateListener(this.sessionUpdateListener.bind(this));
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -213,7 +246,7 @@
|
|||
clearInterval(this.timer);
|
||||
this.updateDisplayMessage();
|
||||
|
||||
// continue to play media locally
|
||||
//// continue to play media locally
|
||||
//console.log("current time: " + this.currentMediaTime);
|
||||
//this.playMediaLocally(this.currentMediaTime);
|
||||
this.updateMediaControlUI();
|
||||
|
@ -695,7 +728,11 @@
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
if (this.hasReceivers) {
|
||||
document.getElementById("btnCast").className = "btnCast btnDefaultCast";
|
||||
document.getElementById("video-ccastButton").removeAttribute("style");
|
||||
this.initializeLocalPlayer();
|
||||
}
|
||||
|
||||
if (this.deviceState == DEVICE_STATE.ACTIVE) {
|
||||
|
@ -722,15 +759,15 @@
|
|||
}
|
||||
};
|
||||
|
||||
window.CastPlayer = CastPlayer;
|
||||
|
||||
var castPlayer = new CastPlayer();
|
||||
|
||||
window.CastPlayer = castPlayer;
|
||||
|
||||
$(document).on('headercreated', ".libraryPage", function () {
|
||||
|
||||
var page = this;
|
||||
|
||||
castPlayer.updateMediaControlUI();
|
||||
//castPlayer.updateMediaControlUI();
|
||||
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue