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

chore: use specific method for checking track

This commit is contained in:
Ivan Schurawel 2022-09-16 13:16:15 -04:00 committed by Ivan Schurawel
parent e871300265
commit e01124cbca

View file

@ -670,6 +670,10 @@ function tryRemoveElement(elem) {
return this.#currentTrackOffset; return this.#currentTrackOffset;
} }
isPrimaryTrack(textTrackIndex) {
return textTrackIndex === this._PRIMARY_TEXT_TRACK_INDEX;
}
isSecondaryTrack(textTrackIndex) { isSecondaryTrack(textTrackIndex) {
return textTrackIndex === this._SECONDARY_TEXT_TRACK_INDEX; return textTrackIndex === this._SECONDARY_TEXT_TRACK_INDEX;
} }
@ -1050,15 +1054,12 @@ function tryRemoveElement(elem) {
* @private * @private
*/ */
destroyCustomRenderedTrackElements(targetTrackIndex) { destroyCustomRenderedTrackElements(targetTrackIndex) {
const destroyPrimaryTrack = targetTrackIndex === this._PRIMARY_TEXT_TRACK_INDEX; if (this.isPrimaryTrack(targetTrackIndex)) {
const destroySecondaryTrack = targetTrackIndex === this._SECONDARY_TEXT_TRACK_INDEX;
if (destroyPrimaryTrack) {
if (this.#videoSubtitlesElem) { if (this.#videoSubtitlesElem) {
tryRemoveElement(this.#videoSubtitlesElem); tryRemoveElement(this.#videoSubtitlesElem);
this.#videoSubtitlesElem = null; this.#videoSubtitlesElem = null;
} }
} else if (destroySecondaryTrack) { } else if (this.isSecondaryTrack(targetTrackIndex)) {
if (this.#videoSecondarySubtitlesElem) { if (this.#videoSecondarySubtitlesElem) {
tryRemoveElement(this.#videoSecondarySubtitlesElem); tryRemoveElement(this.#videoSecondarySubtitlesElem);
this.#videoSecondarySubtitlesElem = null; this.#videoSecondarySubtitlesElem = null;
@ -1099,13 +1100,10 @@ function tryRemoveElement(elem) {
* @private * @private
*/ */
destroyStoredTrackInfo(targetTrackIndex) { destroyStoredTrackInfo(targetTrackIndex) {
const destroyPrimaryTrack = targetTrackIndex === this._PRIMARY_TEXT_TRACK_INDEX; if (this.isPrimaryTrack(targetTrackIndex)) {
const destroySecondaryTrack = targetTrackIndex === this._SECONDARY_TEXT_TRACK_INDEX;
if (destroyPrimaryTrack) {
this.#customTrackIndex = -1; this.#customTrackIndex = -1;
this.#currentTrackEvents = null; this.#currentTrackEvents = null;
} else if (destroySecondaryTrack) { } else if (this.isSecondaryTrack(targetTrackIndex)) {
this.#customSecondaryTrackIndex = -1; this.#customSecondaryTrackIndex = -1;
this.#currentSecondaryTrackEvents = null; this.#currentSecondaryTrackEvents = null;
} else { // destroy all } else { // destroy all