fix: only show secondary if primary sill valid, remove resolveOnClick
This commit is contained in:
parent
e01124cbca
commit
f33699ad8a
2 changed files with 32 additions and 10 deletions
|
@ -1062,8 +1062,21 @@ import { setBackdropTransparency, TRANSPARENCY_LEVEL } from '../../../components
|
|||
return opt;
|
||||
});
|
||||
|
||||
// Only show option if: player has support, has more than 1 subtitle track, has valid secondary tracks, primary subtitle is not off
|
||||
if (playbackManager.hasSecondarySubtitleSupport(player) && streams.length > 1 && secondaryStreams.length > 0 && currentIndex !== -1) {
|
||||
/**
|
||||
* Only show option if:
|
||||
* - player has support
|
||||
* - has more than 1 subtitle track
|
||||
* - has valid secondary tracks
|
||||
* - primary subtitle is not off
|
||||
* - primary subtitle is `External`
|
||||
*/
|
||||
if (
|
||||
playbackManager.hasSecondarySubtitleSupport(player) &&
|
||||
streams.length > 1 &&
|
||||
secondaryStreams.length > 0 &&
|
||||
currentIndex !== -1 &&
|
||||
playbackManager.isSubtitleStreamExternal(currentIndex, player)
|
||||
) {
|
||||
const secondarySubtitleMenuItem = {
|
||||
name: globalize.translate('SecondarySubtitles'),
|
||||
id: 'secondarysubtitle'
|
||||
|
@ -1077,7 +1090,6 @@ import { setBackdropTransparency, TRANSPARENCY_LEVEL } from '../../../components
|
|||
actionsheet.show({
|
||||
title: globalize.translate('Subtitles'),
|
||||
items: menuItems,
|
||||
resolveOnClick: true,
|
||||
positionTo: positionTo
|
||||
}).then(function (id) {
|
||||
if (id === 'secondarysubtitle') {
|
||||
|
|
|
@ -471,15 +471,30 @@ function tryRemoveElement(elem) {
|
|||
destroyFlvPlayer(this);
|
||||
destroyCastPlayer(this);
|
||||
|
||||
let secondaryTrackValid = true;
|
||||
|
||||
this.#subtitleTrackIndexToSetOnPlaying = options.mediaSource.DefaultSubtitleStreamIndex == null ? -1 : options.mediaSource.DefaultSubtitleStreamIndex;
|
||||
if (this.#subtitleTrackIndexToSetOnPlaying != null && this.#subtitleTrackIndexToSetOnPlaying >= 0) {
|
||||
const initialSubtitleStream = options.mediaSource.MediaStreams[this.#subtitleTrackIndexToSetOnPlaying];
|
||||
if (!initialSubtitleStream || initialSubtitleStream.DeliveryMethod === 'Encode') {
|
||||
this.#subtitleTrackIndexToSetOnPlaying = -1;
|
||||
}
|
||||
// secondary track should not be shown if primary track is no longer `External` or is not on
|
||||
if (initialSubtitleStream && initialSubtitleStream.DeliveryMethod !== 'External') {
|
||||
secondaryTrackValid = false;
|
||||
}
|
||||
} else {
|
||||
secondaryTrackValid = false;
|
||||
}
|
||||
// Continue using the secondary track that has been set during this watch session
|
||||
const currentSecondaryTrackIndex = playbackManager.getSecondarySubtitleStreamIndex();
|
||||
|
||||
// Get the secondary track that has been set during this watch session
|
||||
let currentSecondaryTrackIndex = playbackManager.getSecondarySubtitleStreamIndex();
|
||||
|
||||
if (!secondaryTrackValid) {
|
||||
currentSecondaryTrackIndex = -1;
|
||||
playbackManager.setSecondarySubtitleStreamIndex(currentSecondaryTrackIndex);
|
||||
}
|
||||
|
||||
this.#secondarySubtitleTrackIndexToSetOnPlaying = currentSecondaryTrackIndex == null ? -1 : currentSecondaryTrackIndex;
|
||||
if (this.#secondarySubtitleTrackIndexToSetOnPlaying != null && this.#secondarySubtitleTrackIndexToSetOnPlaying >= 0) {
|
||||
const initialSecondarySubtitleStream = options.mediaSource.MediaStreams[this.#secondarySubtitleTrackIndexToSetOnPlaying];
|
||||
|
@ -1118,11 +1133,6 @@ function tryRemoveElement(elem) {
|
|||
* @private
|
||||
*/
|
||||
destroyCustomTrack(videoElement, targetTrackIndex) {
|
||||
if (this.#resizeObserver) {
|
||||
this.#resizeObserver.disconnect();
|
||||
this.#resizeObserver = null;
|
||||
}
|
||||
|
||||
this.destroyCustomRenderedTrackElements(targetTrackIndex);
|
||||
this.destroyNativeTracks(videoElement, targetTrackIndex);
|
||||
this.destroyStoredTrackInfo(targetTrackIndex);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue