Skip to content

Commit

Permalink
Fix type of SourceObject, MediaObject
Browse files Browse the repository at this point in the history
  • Loading branch information
mister-ben committed Dec 12, 2024
1 parent dd7f1ff commit 74c1316
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/js/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ class Component {
* An object that contains width and height values of the `Component`s
* computed style. Uses `window.getComputedStyle`.
*
* @typedef {Object} Component~DimensionObject
* @typedef {Object} DimensionObject
*
* @property {number} width
* The width of the `Component`s computed style.
Expand All @@ -1263,7 +1263,7 @@ class Component {
*
* Uses `window.getComputedStyle`.
*
* @return {Component~DimensionObject}
* @return {DimensionObject}
* The computed dimensions of the component's element.
*/
currentDimensions() {
Expand Down
16 changes: 9 additions & 7 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -3534,7 +3534,7 @@ class Player extends Component {
/**
* Executes source setting and getting logic
*
* @param {SourceObject|SourceObject[]|string} [source]
* @param {string|SourceObject|Array.<SourceObject|string>} [source]
* A SourceObject, an array of SourceObjects, or a string referencing
* a URL to a media source. It is _highly recommended_ that an object
* or array of objects is used here, so that source selection
Expand Down Expand Up @@ -3645,7 +3645,7 @@ class Player extends Component {
/**
* Get or set the video source.
*
* @param {SourceObject|SourceObject[]|string} [source]
* @param {string|SourceObject|Array.<SourceObject|string>} [source]
* A SourceObject, an array of SourceObjects, or a string referencing
* a URL to a media source. It is _highly recommended_ that an object
* or array of objects is used here, so that source selection
Expand Down Expand Up @@ -5114,8 +5114,10 @@ class Player extends Component {
* Properties that are not part of this type description will be retained; so,
* this can be viewed as a generic metadata storage mechanism as well.
*
* Contains properties from MediaMetadata
*
* @see {@link https://wicg.github.io/mediasession/#the-mediametadata-interface}
* @typedef {Object} Player~MediaObject
* @typedef {Object} MediaObject
*
* @property {string} [album]
* Unused, except if this object is passed to the `MediaSession`
Expand All @@ -5133,7 +5135,7 @@ class Player extends Component {
* @property {string} [poster]
* URL to an image that will display before playback.
*
* @property {SourceObject|SourceObject[]|string} [src]
* @property {string|SourceObject|Array.<SourceObject|string>} [src]
* A single source object, an array of source objects, or a string
* referencing a URL to a media source. It is _highly recommended_
* that an object or array of objects is used here, so that source
Expand All @@ -5156,7 +5158,7 @@ class Player extends Component {
/**
* Populate the player using a {@link Player~MediaObject|MediaObject}.
*
* @param {Player~MediaObject} media
* @param {MediaObject} media
* A media object.
*
* @param {Function} ready
Expand Down Expand Up @@ -5214,9 +5216,9 @@ class Player extends Component {
* Get a clone of the current {@link Player~MediaObject} for this player.
*
* If the `loadMedia` method has not been used, will attempt to return a
* {@link Player~MediaObject} based on the current state of the player.
* {@link MediaObject} based on the current state of the player.
*
* @return {Player~MediaObject}
* @return {MediaObject}
*/
getMedia() {
if (!this.cache_.media) {
Expand Down
18 changes: 10 additions & 8 deletions src/js/tech/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {NORMAL as TRACK_TYPES, REMOTE} from '../tracks/track-types';
import setupSourceset from './setup-sourceset';
import {silencePromise} from '../utils/promise';

/** @import { SourceObject } from './tech' */

/**
* HTML5 Media Controller - Wrapper for HTML5 Media API
*
Expand Down Expand Up @@ -765,10 +767,10 @@ class Html5 extends Tech {
* A getter/setter for the `Html5` Tech's source object.
* > Note: Please use {@link Html5#setSource}
*
* @param {Tech~SourceObject} [src]
* @param {SourceObject} [src]
* The source object you want to set on the `HTML5` techs element.
*
* @return {Tech~SourceObject|undefined}
* @return {string|undefined}
* - The current source object when a source is not passed in.
* - undefined when setting
*
Expand Down Expand Up @@ -856,8 +858,8 @@ class Html5 extends Tech {
* Get the current source on the `HTML5` Tech. Falls back to returning the source from
* the HTML5 media element.
*
* @return {Tech~SourceObject}
* The current source object from the HTML5 tech. With a fallback to the
* @return {string}
* The current source from the HTML5 tech. With a fallback to the
* elements source.
*/
currentSrc() {
Expand Down Expand Up @@ -1934,7 +1936,7 @@ Html5.resetMediaElement = function(el) {
* {@link Tech~SourceObject} for the media.
*
* @method Html5#setSrc
* @param {Tech~SourceObject} src
* @param {string} src
* The source object to set as the current source.
*
* @see [Spec]{@link https://www.w3.org/TR/html5/embedded-content-0.html#dom-media-src}
Expand Down Expand Up @@ -2078,7 +2080,7 @@ Tech.withSourceHandlers(Html5);
/**
* Native source handler for Html5, simply passes the source to the media element.
*
* @property {Tech~SourceObject} source
* @property {SourceObject} source
* The source object
*
* @property {Html5} tech
Expand Down Expand Up @@ -2107,7 +2109,7 @@ Html5.nativeSourceHandler.canPlayType = function(type) {
/**
* Check if the media element can handle a source natively.
*
* @param {Tech~SourceObject} source
* @param {SourceObject} source
* The source object
*
* @param {Object} [options]
Expand Down Expand Up @@ -2135,7 +2137,7 @@ Html5.nativeSourceHandler.canHandleSource = function(source, options) {
/**
* Pass the source to the native media element.
*
* @param {Tech~SourceObject} source
* @param {SourceObject} source
* The source object
*
* @param {Html5} tech
Expand Down
3 changes: 2 additions & 1 deletion src/js/tech/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {toTitleCase} from '../utils/str.js';

/** @import Player from '../player' */
/** @import Tech from '../tech/tech' */
/** @import { SourceObject } from './tech/tech' */

const middlewares = {};
const middlewareInstances = {};
Expand Down Expand Up @@ -75,7 +76,7 @@ export function getMiddleware(type) {
* @param {Player} player
* A {@link Player} instance.
*
* @param {Tech~SourceObject} src
* @param {SourceObject} src
* A source object.
*
* @param {Function}
Expand Down
10 changes: 6 additions & 4 deletions src/js/utils/filter-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
import {isObject} from './obj';
import {getMimetype} from './mimetypes';

/** @import { SourceObject } from '../tech/tech' */

/**
* Filter out single bad source objects or multiple source objects in an
* array. Also flattens nested source object arrays into a 1 dimensional
* array of source objects.
*
* @param {Tech~SourceObject|Tech~SourceObject[]} src
* @param {string|SourceObject|Array.<SourceObject|string>} src
* The src object to filter
*
* @return {Tech~SourceObject[]}
* @return {SourceObject[]}
* An array of sourceobjects containing only valid sources
*
* @private
Expand Down Expand Up @@ -50,9 +52,9 @@ const filterSource = function(src) {
/**
* Checks src mimetype, adding it when possible
*
* @param {Tech~SourceObject} src
* @param {SourceObject} src
* The src object to check
* @return {Tech~SourceObject}
* @return {SourceObject}
* src Object with known type
*/
function fixSource(src) {
Expand Down

0 comments on commit 74c1316

Please sign in to comment.