diff --git a/types/video.js/index.d.ts b/types/video.js/index.d.ts index 5fb8aa0b29..5420735177 100644 --- a/types/video.js/index.d.ts +++ b/types/video.js/index.d.ts @@ -3863,6 +3863,56 @@ declare namespace videojs { getTagSettings(tag: Element): any; }; + namespace Player { + /** + * An object that describes a single piece of media. + * 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. + */ + interface MediaObject { + /** + * Unused, except if this object is passed to the MediaSession API. + */ + album?: string; + + /** + * Unused, except if this object is passed to the MediaSession API. + */ + artist?: string; + + /** + * Unused, except if this object is passed to the MediaSession API. If not specified, will be populated via the poster, if available. + */ + artwork?: any[]; + + /** + * URL to an image that will display before playback. + */ + poster?: string; + + /** + * 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 selection algorithms can take the type into account. + */ + src?: string | Tech.SourceObject | Tech.SourceObject[]; + + /** + * Unused, except if this object is passed to the MediaSession API. + */ + title?: string; + + /** + * An array of objects to be used to create text tracks, following the native track element format. + * For ease of removal, these will be created as "remote" text tracks and set to automatically clean up on source changes. + */ + textTracks?: any[]; + + /** + * 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. + */ + [key: string]: any; + } + } + type PlayerOptions = VideoJsPlayerOptions; /** @@ -6331,6 +6381,12 @@ export interface VideoJsPlayer extends videojs.Component { */ exitFullWindow(): void; + /** + * Get a clone of the current Player~MediaObject for this player. + * If the loadMedia method has not been used, will attempt to return a Player~MediaObject based on the current state of the player. + */ + getMedia(): videojs.Player.MediaObject; + /** * Reports whether or not a player has a plugin available. * @@ -6434,6 +6490,11 @@ export interface VideoJsPlayer extends videojs.Component { */ load(): void; + /** + * Populate the player using a MediaObject. + */ + loadMedia(media: videojs.Player.MediaObject, ready: () => any): void; + /** * Get or set the loop attribute on the video element. * diff --git a/types/video.js/video.js-tests.ts b/types/video.js/video.js-tests.ts index 0bb906b170..8259736438 100644 --- a/types/video.js/video.js-tests.ts +++ b/types/video.js/video.js-tests.ts @@ -153,6 +153,15 @@ function testPlugin(player: videojs.Player, options: {}) { this.player.on('pause', () => { videojs.log('playback ended'); }); + + const media = this.player.getMedia(); + + this.player.loadMedia({ + src: "http://www.example.com/path/to/video.mp4", + poster: "http://www.example.com/path/to/image.jpg", + }, () => { + videojs.log('loadMedia ready!'); + }); } }