mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Cast updates
* Store runtimeTicks in customData for persistence on reload * Enabled seeking * Fix for pause/mute state * Fix for slider enable/disable
This commit is contained in:
parent
a463914607
commit
7495ac44b0
2 changed files with 25 additions and 14 deletions
|
@ -273,7 +273,7 @@
|
||||||
|
|
||||||
var request = new chrome.cast.media.LoadRequest(castMediaInfo);
|
var request = new chrome.cast.media.LoadRequest(castMediaInfo);
|
||||||
request.autoplay = true;
|
request.autoplay = true;
|
||||||
request.currentTime = 0;
|
request.currentTime = startTimeTicks ? startTimeTicks / 10000000 : 0;
|
||||||
|
|
||||||
this.castPlayerState = PLAYER_STATE.LOADING;
|
this.castPlayerState = PLAYER_STATE.LOADING;
|
||||||
this.session.loadMedia(request,
|
this.session.loadMedia(request,
|
||||||
|
@ -289,7 +289,7 @@
|
||||||
|
|
||||||
console.log("chromecast new media session ID:" + mediaSession.mediaSessionId + ' (' + how + ')');
|
console.log("chromecast new media session ID:" + mediaSession.mediaSessionId + ' (' + how + ')');
|
||||||
this.currentMediaSession = mediaSession;
|
this.currentMediaSession = mediaSession;
|
||||||
this.currentMediaTime = this.session.media[0].currentTime;
|
this.currentMediaTime = mediaSession.currentTime;
|
||||||
|
|
||||||
if (how == 'loadMedia') {
|
if (how == 'loadMedia') {
|
||||||
this.castPlayerState = PLAYER_STATE.PLAYING;
|
this.castPlayerState = PLAYER_STATE.PLAYING;
|
||||||
|
@ -298,7 +298,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (how == 'activeSession') {
|
if (how == 'activeSession') {
|
||||||
this.castPlayerState = this.session.media[0].playerState;
|
this.castPlayerState = mediaSession.playerState;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.castPlayerState == PLAYER_STATE.PLAYING) {
|
if (this.castPlayerState == PLAYER_STATE.PLAYING) {
|
||||||
|
@ -307,7 +307,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentMediaSession.addUpdateListener(this.onMediaStatusUpdate.bind(this));
|
this.currentMediaSession.addUpdateListener(this.onMediaStatusUpdate.bind(this));
|
||||||
this.currentMediaDuration = this.currentMediaSession.media.duration;
|
this.currentMediaDuration = mediaSession.media.customData.runTimeTicks;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -474,7 +474,7 @@
|
||||||
CastPlayer.prototype.seekMedia = function (event) {
|
CastPlayer.prototype.seekMedia = function (event) {
|
||||||
var pos = parseInt(event);
|
var pos = parseInt(event);
|
||||||
|
|
||||||
var curr = parseInt(this.currentMediaTime + this.currentMediaDuration * pos);
|
var curr = pos / 10000000;
|
||||||
|
|
||||||
if (this.castPlayerState != PLAYER_STATE.PLAYING && this.castPlayerState != PLAYER_STATE.PAUSED) {
|
if (this.castPlayerState != PLAYER_STATE.PLAYING && this.castPlayerState != PLAYER_STATE.PAUSED) {
|
||||||
return;
|
return;
|
||||||
|
@ -482,7 +482,7 @@
|
||||||
|
|
||||||
this.currentMediaTime = curr;
|
this.currentMediaTime = curr;
|
||||||
console.log('Seeking ' + this.currentMediaSession.sessionId + ':' +
|
console.log('Seeking ' + this.currentMediaSession.sessionId + ':' +
|
||||||
this.currentMediaSession.mediaSessionId + ' to ' + pos + "%");
|
this.currentMediaSession.mediaSessionId + ' to ' + curr);
|
||||||
var request = new chrome.cast.media.SeekRequest();
|
var request = new chrome.cast.media.SeekRequest();
|
||||||
request.currentTime = this.currentMediaTime;
|
request.currentTime = this.currentMediaTime;
|
||||||
this.currentMediaSession.seek(request,
|
this.currentMediaSession.seek(request,
|
||||||
|
@ -538,6 +538,14 @@
|
||||||
* Update progress bar based on timer
|
* Update progress bar based on timer
|
||||||
*/
|
*/
|
||||||
CastPlayer.prototype.updateProgressBarByTimer = function () {
|
CastPlayer.prototype.updateProgressBarByTimer = function () {
|
||||||
|
if (!this.currentMediaTime) {
|
||||||
|
this.currentMediaDuration = this.session.media[0].currentTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.currentMediaDuration) {
|
||||||
|
this.currentMediaDuration = this.session.media[0].media.customData.runTimeTicks;
|
||||||
|
}
|
||||||
|
|
||||||
var pp = 0;
|
var pp = 0;
|
||||||
if (this.currentMediaDuration > 0) {
|
if (this.currentMediaDuration > 0) {
|
||||||
pp = Number(this.currentMediaTime / this.currentMediaDuration).toFixed(3);
|
pp = Number(this.currentMediaTime / this.currentMediaDuration).toFixed(3);
|
||||||
|
@ -548,7 +556,7 @@
|
||||||
$(this).trigger("/playback/update",
|
$(this).trigger("/playback/update",
|
||||||
[{
|
[{
|
||||||
positionTicks: this.currentMediaTime * 10000000,
|
positionTicks: this.currentMediaTime * 10000000,
|
||||||
runtimeTicks: this.currentMediaDuration * 10000000
|
runtimeTicks: this.currentMediaDuration
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,7 +793,8 @@
|
||||||
userId: Dashboard.getCurrentUserId(),
|
userId: Dashboard.getCurrentUserId(),
|
||||||
deviceName: ApiClient.deviceName(),
|
deviceName: ApiClient.deviceName(),
|
||||||
//deviceId: ApiClient.deviceId(),
|
//deviceId: ApiClient.deviceId(),
|
||||||
startTimeTicks: startTimeTicks || 0
|
startTimeTicks: startTimeTicks || 0,
|
||||||
|
runTimeTicks: item.RunTimeTicks
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1287,9 +1296,8 @@
|
||||||
self.currentTimeElement.html(timeText);
|
self.currentTimeElement.html(timeText);
|
||||||
};
|
};
|
||||||
|
|
||||||
self.changeStream = function (position) {
|
self.changeStream = self.seek = function (position) {
|
||||||
console.log("seek", position);
|
castPlayer.seekMedia(position);
|
||||||
////castPlayer.seekMedia(position);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.removeFromPlaylist = function (i) {
|
self.removeFromPlaylist = function (i) {
|
||||||
|
@ -1374,7 +1382,9 @@
|
||||||
canSeek: self.positionTicks < self.runtimeTicks,
|
canSeek: self.positionTicks < self.runtimeTicks,
|
||||||
positionTicks: self.positionTicks,
|
positionTicks: self.positionTicks,
|
||||||
runtimeTicks: self.runtimeTicks,
|
runtimeTicks: self.runtimeTicks,
|
||||||
volumeLevel: castPlayer.currentVolume * 100
|
volumeLevel: castPlayer.currentVolume * 100,
|
||||||
|
isPaused: self.isPaused,
|
||||||
|
isMuted: self.isMuted
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,16 +230,17 @@
|
||||||
volumeSlider.slider('refresh');
|
volumeSlider.slider('refresh');
|
||||||
|
|
||||||
if (!isPositionSliderActive) {
|
if (!isPositionSliderActive) {
|
||||||
|
|
||||||
if (state.canSeek) {
|
if (state.canSeek) {
|
||||||
|
|
||||||
var pct = state.positionTicks / state.runtimeTicks;
|
var pct = state.positionTicks / state.runtimeTicks;
|
||||||
pct *= 100;
|
pct *= 100;
|
||||||
|
|
||||||
positionSlider.val(pct).prop('disabled', '');
|
positionSlider.val(pct).slider("enable");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
positionSlider.val(0).prop('disabled', 'disabled');
|
positionSlider.val(0).slider("disable");
|
||||||
}
|
}
|
||||||
|
|
||||||
positionSlider.slider('refresh');
|
positionSlider.slider('refresh');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue