Skip to content

Commit

Permalink
use standard types for TextTracks
Browse files Browse the repository at this point in the history
  • Loading branch information
mister-ben committed Dec 12, 2024
1 parent c1d4bd0 commit dd7f1ff
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/js/tracks/html-track-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class HTMLTrackElement extends EventTarget {
* @param {Tech} options.tech
* A reference to the tech that owns this HTMLTrackElement.
*
* @param {TextTrack~Kind} [options.kind='subtitles']
* @param {TextTrackKind} [options.kind='subtitles']
* A valid text track kind.
*
* @param {TextTrack~Mode} [options.mode='disabled']
* @param {TextTrackMode} [options.mode='disabled']
* A valid text track mode.
*
* @param {string} [options.id='vjs_track_' + Guid.newGUID()]
Expand Down
20 changes: 1 addition & 19 deletions src/js/tracks/text-track-cue-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,6 @@
* @file text-track-cue-list.js
*/

/**
* @typedef {Object} TextTrackCueList~TextTrackCue
*
* @property {string} id
* The unique id for this text track cue
*
* @property {number} startTime
* The start time for this text track cue
*
* @property {number} endTime
* The end time for this text track cue
*
* @property {boolean} pauseOnExit
* Pause when the end time is reached if true.
*
* @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackcue}
*/

/**
* A List of TextTrackCues.
*
Expand Down Expand Up @@ -91,7 +73,7 @@ class TextTrackCueList {
* @param {string} id
* The id of the cue that should be searched for.
*
* @return {TextTrackCueList~TextTrackCue|null}
* @return {TextTrackCue|null}
* A single cue or null if none was found.
*/
getCueById(id) {
Expand Down
16 changes: 8 additions & 8 deletions src/js/tracks/text-track.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import TextTrackCueList from './text-track-cue-list';
import * as Fn from '../utils/fn.js';
import {TextTrackKind, TextTrackMode} from './track-enums';
import {TextTrackKind as TextTrackKindEnum, TextTrackMode as TextTrackModeEnum} from './track-enums';
import log from '../utils/log.js';
import window from 'global/window';
import Track from './track.js';
Expand Down Expand Up @@ -133,10 +133,10 @@ class TextTrack extends Track {
* @param {Tech} options.tech
* A reference to the tech that owns this TextTrack.
*
* @param {TextTrack~Kind} [options.kind='subtitles']
* @param {TextTrackKind} [options.kind='subtitles']
* A valid text track kind.
*
* @param {TextTrack~Mode} [options.mode='disabled']
* @param {TextTrackMode} [options.mode='disabled']
* A valid text track mode.
*
* @param {string} [options.id='vjs_track_' + Guid.newGUID()]
Expand Down Expand Up @@ -164,10 +164,10 @@ class TextTrack extends Track {
}

const settings = merge(options, {
kind: TextTrackKind[options.kind] || 'subtitles',
kind: TextTrackKindEnum[options.kind] || 'subtitles',
language: options.language || options.srclang || ''
});
let mode = TextTrackMode[settings.mode] || 'disabled';
let mode = TextTrackModeEnum[settings.mode] || 'disabled';
const default_ = settings.default;

if (settings.kind === 'metadata' || settings.kind === 'chapters') {
Expand Down Expand Up @@ -255,7 +255,7 @@ class TextTrack extends Track {
return mode;
},
set(newMode) {
if (!TextTrackMode[newMode]) {
if (!TextTrackModeEnum[newMode]) {
return;
}
if (mode === newMode) {
Expand Down Expand Up @@ -387,7 +387,7 @@ class TextTrack extends Track {
/**
* Add a cue to the internal list of cues.
*
* @param {TextTrack~Cue} cue
* @param {TextTrackCue} cue
* The cue to add to our internal list
*/
addCue(originalCue) {
Expand Down Expand Up @@ -423,7 +423,7 @@ class TextTrack extends Track {
/**
* Remove a cue from our internal list
*
* @param {TextTrack~Cue} removeCue
* @param {TextTrackCue} removeCue
* The cue to remove from our internal list
*/
removeCue(removeCue) {
Expand Down
2 changes: 0 additions & 2 deletions src/js/tracks/track-enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export const AudioTrackKind = {
* All possible `TextTrackKind`s
*
* @see https://html.spec.whatwg.org/multipage/embedded-content.html#dom-texttrack-kind
* @typedef TextTrack~Kind
* @enum
*/
export const TextTrackKind = {
Expand All @@ -53,7 +52,6 @@ export const TextTrackKind = {
* All possible `TextTrackMode`s
*
* @see https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackmode
* @typedef TextTrack~Mode
* @enum
*/
export const TextTrackMode = {
Expand Down

0 comments on commit dd7f1ff

Please sign in to comment.