mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
fix: limit secondary to non-SSA/ASS subtitles
This commit is contained in:
parent
f33699ad8a
commit
9ddafb063b
3 changed files with 22 additions and 8 deletions
|
@ -876,15 +876,28 @@ class PlaybackManager {
|
|||
});
|
||||
};
|
||||
|
||||
self.hasSecondarySubtitleSupport = function (player = self._currentPlayer) {
|
||||
self.playerHasSecondarySubtitleSupport = function (player = self._currentPlayer) {
|
||||
if (!player) return false;
|
||||
return Boolean(player.supports('SecondarySubtitles'));
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if:
|
||||
* - the track can be used directly as a secondary subtitle
|
||||
* - or if it can be paired with a secondary subtitle when used as a primary subtitle
|
||||
*/
|
||||
self.trackHasSecondarySubtitleSupport = function (track, player = self._currentPlayer) {
|
||||
if (!player || !self.playerHasSecondarySubtitleSupport(player)) return false;
|
||||
const format = (track.Codec || '').toLowerCase();
|
||||
// Currently, only non-SSA/non-ASS external subtitles are supported.
|
||||
// Showing secondary subtitles does not work with any SSA/ASS subtitle combinations because
|
||||
// of the complexity of how they are rendered and the risk of the subtitles overlapping
|
||||
return format !== 'ssa' && format !== 'ass' && getDeliveryMethod(track) === 'External';
|
||||
};
|
||||
|
||||
self.secondarySubtitleTracks = function (player = self._currentPlayer) {
|
||||
const streams = self.subtitleTracks(player);
|
||||
// Currently, only External subtitles are supported
|
||||
return streams.filter((stream) => getDeliveryMethod(stream) === 'External');
|
||||
return streams.filter((stream) => self.trackHasSecondarySubtitleSupport(stream, player));
|
||||
};
|
||||
|
||||
function getCurrentSubtitleStream(player) {
|
||||
|
@ -1575,7 +1588,7 @@ class PlaybackManager {
|
|||
|
||||
self.setSecondarySubtitleStreamIndex = function (index, player) {
|
||||
player = player || self._currentPlayer;
|
||||
if (!self.hasSecondarySubtitleSupport(player)) return;
|
||||
if (!self.playerHasSecondarySubtitleSupport(player)) return;
|
||||
if (player && !enableLocalPlaylistManagement(player)) {
|
||||
try {
|
||||
return player.setSecondarySubtitleStreamIndex(index);
|
||||
|
|
|
@ -990,7 +990,7 @@ import { setBackdropTransparency, TRANSPARENCY_LEVEL } from '../../../components
|
|||
|
||||
function showSecondarySubtitlesMenu(actionsheet, positionTo) {
|
||||
const player = currentPlayer;
|
||||
if (!playbackManager.hasSecondarySubtitleSupport(player)) return;
|
||||
if (!playbackManager.playerHasSecondarySubtitleSupport(player)) return;
|
||||
let currentIndex = playbackManager.getSecondarySubtitleStreamIndex(player);
|
||||
const streams = playbackManager.secondarySubtitleTracks(player);
|
||||
|
||||
|
@ -1071,7 +1071,7 @@ import { setBackdropTransparency, TRANSPARENCY_LEVEL } from '../../../components
|
|||
* - primary subtitle is `External`
|
||||
*/
|
||||
if (
|
||||
playbackManager.hasSecondarySubtitleSupport(player) &&
|
||||
playbackManager.playerHasSecondarySubtitleSupport(player) &&
|
||||
streams.length > 1 &&
|
||||
secondaryStreams.length > 0 &&
|
||||
currentIndex !== -1 &&
|
||||
|
|
|
@ -478,9 +478,10 @@ function tryRemoveElement(elem) {
|
|||
const initialSubtitleStream = options.mediaSource.MediaStreams[this.#subtitleTrackIndexToSetOnPlaying];
|
||||
if (!initialSubtitleStream || initialSubtitleStream.DeliveryMethod === 'Encode') {
|
||||
this.#subtitleTrackIndexToSetOnPlaying = -1;
|
||||
secondaryTrackValid = false;
|
||||
}
|
||||
// secondary track should not be shown if primary track is no longer `External` or is not on
|
||||
if (initialSubtitleStream && initialSubtitleStream.DeliveryMethod !== 'External') {
|
||||
// secondary track should not be shown if primary track is no longer a valid pair
|
||||
if (initialSubtitleStream && !playbackManager.trackHasSecondarySubtitleSupport(initialSubtitleStream)) {
|
||||
secondaryTrackValid = false;
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue