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;
|
if (!player) return false;
|
||||||
return Boolean(player.supports('SecondarySubtitles'));
|
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) {
|
self.secondarySubtitleTracks = function (player = self._currentPlayer) {
|
||||||
const streams = self.subtitleTracks(player);
|
const streams = self.subtitleTracks(player);
|
||||||
// Currently, only External subtitles are supported
|
return streams.filter((stream) => self.trackHasSecondarySubtitleSupport(stream, player));
|
||||||
return streams.filter((stream) => getDeliveryMethod(stream) === 'External');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function getCurrentSubtitleStream(player) {
|
function getCurrentSubtitleStream(player) {
|
||||||
|
@ -1575,7 +1588,7 @@ class PlaybackManager {
|
||||||
|
|
||||||
self.setSecondarySubtitleStreamIndex = function (index, player) {
|
self.setSecondarySubtitleStreamIndex = function (index, player) {
|
||||||
player = player || self._currentPlayer;
|
player = player || self._currentPlayer;
|
||||||
if (!self.hasSecondarySubtitleSupport(player)) return;
|
if (!self.playerHasSecondarySubtitleSupport(player)) return;
|
||||||
if (player && !enableLocalPlaylistManagement(player)) {
|
if (player && !enableLocalPlaylistManagement(player)) {
|
||||||
try {
|
try {
|
||||||
return player.setSecondarySubtitleStreamIndex(index);
|
return player.setSecondarySubtitleStreamIndex(index);
|
||||||
|
|
|
@ -990,7 +990,7 @@ import { setBackdropTransparency, TRANSPARENCY_LEVEL } from '../../../components
|
||||||
|
|
||||||
function showSecondarySubtitlesMenu(actionsheet, positionTo) {
|
function showSecondarySubtitlesMenu(actionsheet, positionTo) {
|
||||||
const player = currentPlayer;
|
const player = currentPlayer;
|
||||||
if (!playbackManager.hasSecondarySubtitleSupport(player)) return;
|
if (!playbackManager.playerHasSecondarySubtitleSupport(player)) return;
|
||||||
let currentIndex = playbackManager.getSecondarySubtitleStreamIndex(player);
|
let currentIndex = playbackManager.getSecondarySubtitleStreamIndex(player);
|
||||||
const streams = playbackManager.secondarySubtitleTracks(player);
|
const streams = playbackManager.secondarySubtitleTracks(player);
|
||||||
|
|
||||||
|
@ -1071,7 +1071,7 @@ import { setBackdropTransparency, TRANSPARENCY_LEVEL } from '../../../components
|
||||||
* - primary subtitle is `External`
|
* - primary subtitle is `External`
|
||||||
*/
|
*/
|
||||||
if (
|
if (
|
||||||
playbackManager.hasSecondarySubtitleSupport(player) &&
|
playbackManager.playerHasSecondarySubtitleSupport(player) &&
|
||||||
streams.length > 1 &&
|
streams.length > 1 &&
|
||||||
secondaryStreams.length > 0 &&
|
secondaryStreams.length > 0 &&
|
||||||
currentIndex !== -1 &&
|
currentIndex !== -1 &&
|
||||||
|
|
|
@ -478,9 +478,10 @@ function tryRemoveElement(elem) {
|
||||||
const initialSubtitleStream = options.mediaSource.MediaStreams[this.#subtitleTrackIndexToSetOnPlaying];
|
const initialSubtitleStream = options.mediaSource.MediaStreams[this.#subtitleTrackIndexToSetOnPlaying];
|
||||||
if (!initialSubtitleStream || initialSubtitleStream.DeliveryMethod === 'Encode') {
|
if (!initialSubtitleStream || initialSubtitleStream.DeliveryMethod === 'Encode') {
|
||||||
this.#subtitleTrackIndexToSetOnPlaying = -1;
|
this.#subtitleTrackIndexToSetOnPlaying = -1;
|
||||||
|
secondaryTrackValid = false;
|
||||||
}
|
}
|
||||||
// secondary track should not be shown if primary track is no longer `External` or is not on
|
// secondary track should not be shown if primary track is no longer a valid pair
|
||||||
if (initialSubtitleStream && initialSubtitleStream.DeliveryMethod !== 'External') {
|
if (initialSubtitleStream && !playbackManager.trackHasSecondarySubtitleSupport(initialSubtitleStream)) {
|
||||||
secondaryTrackValid = false;
|
secondaryTrackValid = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue