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

Only load subtitle when direct play/remux

This commit is contained in:
gnattu 2024-09-22 00:36:29 +08:00
parent 0dbd659bc4
commit 2d12aec9b4

View file

@ -1,6 +1,7 @@
import DOMPurify from 'dompurify'; import DOMPurify from 'dompurify';
import browser from '../../scripts/browser'; import browser from '../../scripts/browser';
import appSettings from '../../scripts/settings/appSettings';
import { appHost } from '../../components/apphost'; import { appHost } from '../../components/apphost';
import loading from '../../components/loading/loading'; import loading from '../../components/loading/loading';
import dom from '../../scripts/dom'; import dom from '../../scripts/dom';
@ -1566,15 +1567,50 @@ export class HtmlVideoPlayer {
return t.Index === streamIndex; return t.Index === streamIndex;
})[0]; })[0];
this.setTrackForDisplay(this.#mediaElement, track, targetTextTrackIndex); // This play method can only check if it is real direct play, and will mark Remux as Transcode as well
if (enableNativeTrackSupport(this._currentPlayOptions?.mediaSource, track)) { const isDirectPlay = this._currentPlayOptions.playMethod === "DirectPlay";
if (streamIndex !== -1) { const burnInWhenTranscoding = appSettings.alwaysBurnInSubtitleWhenTranscoding();
this.setCueAppearance();
} if (!isDirectPlay && burnInWhenTranscoding) {
const apiClient = ServerConnections.getApiClient(this._currentPlayOptions.item.ServerId);
const sessionPromise = apiClient.getSessions({
deviceId: apiClient.deviceId()
}).then(function (sessions) {
return sessions[0] || {};;
}, function () {
return Promise.resolve({});
});
const player = this;
sessionPromise.then((s) => {
if (!s.TranscodingInfo || s.TranscodingInfo?.IsVideoDirect) {
player.setTrackForDisplay(player.#mediaElement, track, targetTextTrackIndex);
if (enableNativeTrackSupport(player._currentPlayOptions?.mediaSource, track)) {
if (streamIndex !== -1) {
player.setCueAppearance();
}
} else {
// null these out to disable the player's native display (handled below)
streamIndex = -1;
track = null;
}
} else {
// unset stream when switching to transcode
player.setTrackForDisplay(player.#mediaElement, null, -1);
}
})
} else { } else {
// null these out to disable the player's native display (handled below) this.setTrackForDisplay(this.#mediaElement, track, targetTextTrackIndex);
streamIndex = -1; if (enableNativeTrackSupport(this._currentPlayOptions?.mediaSource, track)) {
track = null; if (streamIndex !== -1) {
this.setCueAppearance();
}
} else {
// null these out to disable the player's native display (handled below)
streamIndex = -1;
track = null;
}
} }
} }