mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Refactor sessionPromise
This commit is contained in:
parent
fc9485c49d
commit
1216305992
1 changed files with 27 additions and 26 deletions
|
@ -1571,47 +1571,48 @@ export class HtmlVideoPlayer {
|
||||||
const isDirectPlay = this._currentPlayOptions.playMethod === 'DirectPlay';
|
const isDirectPlay = this._currentPlayOptions.playMethod === 'DirectPlay';
|
||||||
const burnInWhenTranscoding = appSettings.alwaysBurnInSubtitleWhenTranscoding();
|
const burnInWhenTranscoding = appSettings.alwaysBurnInSubtitleWhenTranscoding();
|
||||||
|
|
||||||
|
let sessionPromise;
|
||||||
if (!isDirectPlay && burnInWhenTranscoding) {
|
if (!isDirectPlay && burnInWhenTranscoding) {
|
||||||
const apiClient = ServerConnections.getApiClient(this._currentPlayOptions.item.ServerId);
|
const apiClient = ServerConnections.getApiClient(this._currentPlayOptions.item.ServerId);
|
||||||
const sessionPromise = apiClient.getSessions({
|
sessionPromise = apiClient.getSessions({
|
||||||
deviceId: apiClient.deviceId()
|
deviceId: apiClient.deviceId()
|
||||||
}).then(function (sessions) {
|
}).then(function (sessions) {
|
||||||
return sessions[0] || {};
|
return sessions[0] || {};
|
||||||
}, function () {
|
}, function () {
|
||||||
return Promise.resolve({});
|
return Promise.resolve({});
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
sessionPromise = Promise.resolve({});
|
||||||
|
}
|
||||||
|
|
||||||
const player = this;
|
const player = this;
|
||||||
|
|
||||||
sessionPromise.then((s) => {
|
sessionPromise.then((s) => {
|
||||||
if (!s.TranscodingInfo || s.TranscodingInfo?.IsVideoDirect) {
|
if (!s.TranscodingInfo || s.TranscodingInfo?.IsVideoDirect) {
|
||||||
player.setTrackForDisplay(player.#mediaElement, track, targetTextTrackIndex);
|
// restore recorded delivery method if any
|
||||||
if (enableNativeTrackSupport(player._currentPlayOptions?.mediaSource, track)) {
|
mediaStreamTextTracks.forEach((t) => {
|
||||||
if (streamIndex !== -1) {
|
t.DeliveryMethod = t.realDeliveryMethod ?? t.DeliveryMethod;
|
||||||
player.setCueAppearance();
|
});
|
||||||
}
|
player.setTrackForDisplay(player.#mediaElement, track, targetTextTrackIndex);
|
||||||
} else {
|
if (enableNativeTrackSupport(player._currentPlayOptions?.mediaSource, track)) {
|
||||||
// null these out to disable the player's native display (handled below)
|
if (streamIndex !== -1) {
|
||||||
streamIndex = -1;
|
player.setCueAppearance();
|
||||||
track = null;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// unset stream when switching to transcode
|
// null these out to disable the player's native display (handled below)
|
||||||
player.setTrackForDisplay(player.#mediaElement, null, -1);
|
streamIndex = -1;
|
||||||
}
|
track = null;
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.setTrackForDisplay(this.#mediaElement, track, targetTextTrackIndex);
|
|
||||||
if (enableNativeTrackSupport(this._currentPlayOptions?.mediaSource, track)) {
|
|
||||||
if (streamIndex !== -1) {
|
|
||||||
this.setCueAppearance();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// null these out to disable the player's native display (handled below)
|
// record the original delivery method and set all delivery method to encode
|
||||||
streamIndex = -1;
|
mediaStreamTextTracks.forEach((t) => {
|
||||||
track = null;
|
t.realDeliveryMethod = t.DeliveryMethod;
|
||||||
|
t.DeliveryMethod = 'Encode';
|
||||||
|
});
|
||||||
|
// unset stream when switching to transcode
|
||||||
|
player.setTrackForDisplay(player.#mediaElement, null, -1);
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue