diff --git a/types/yt-player/index.d.ts b/types/yt-player/index.d.ts index 39575ae0ff..7de093c875 100644 --- a/types/yt-player/index.d.ts +++ b/types/yt-player/index.d.ts @@ -6,18 +6,70 @@ import { EventEmitter } from "events"; interface YouTubePlayerOptions { + /** This parameter indicates the width of the player. */ width?: number; + /** This parameter indicates the height of the player. */ height?: number; + /** + * This parameter indicates whether the initial video will automatically + * start to play when the player loads. The default value is false. + */ autoplay?: boolean; + /** + * This parameter indicates whether closed captions should be shown, even if + * the user has turned captions off. The default behavior is based on user + * preference. + */ captions?: false | string; + /** + * This parameter indicates whether the video player controls are displayed. + * The default value is true. + */ controls?: boolean; + /** + * This parameter indicates whether the player will respond to keyboard + * shortcuts. The default value is true. + */ keyboard?: boolean; + /** + * This parameter indicates whether the player will show a fullscreen + * button. The default value is true. + */ fullscreen?: boolean; + /** + * This parameter indicates whether the player will show video annotations. + * The default value is true. + */ annotations?: boolean; + /** + * This parameter lets you use a YouTube player that does not show a + * YouTube logo. Even when this option is enabled, a small YouTube text + * label will still display in the upper-right corner of a paused video + * when the user's mouse pointer hovers over the player. + */ modestBranding?: boolean; + /** + * This parameter indicates whether the player should show related videos + * from other channels + */ related?: boolean; + /** + * This parameter indicates whether the player should display information + * like the video title and uploader before the video starts playing. The + * default value is true. + * @deprecated Ignored after September 25, 2018 + * @see https://developers.google.com/youtube/player_parameters#release_notes_08_23_2018 + */ info?: boolean; + /** + * The time between onTimeupdate callbacks, in milliseconds. Default is + * 1000. + */ timeupdateFrequency?: number; + /** + * This parameter controls whether videos play inline or fullscreen in an + * HTML5 player on iOS. The default value is true. + */ playsInline?: boolean; } @@ -25,47 +77,177 @@ type YouTubePlayerState = "unstarted" | "ended" | "playing" | "paused" | "buffer type YouTubePlayerQuality = "small" | "medium" | "large" | "hd720" | "hd1080" | "highres" | "default"; +/** + * Simple, robust, blazing-fast YouTube Player API + * + * @see https://github.com/feross/yt-player + */ declare class YouTubePlayer extends EventEmitter { + /** Returns the currently loaded video ID, i.e.what was passed to load(). */ videoId: string; + /** Returns true if destroy() has been called on the player. */ destroyed: boolean; - + /** + * Create a new YouTube player. The player will take the place of the HTML + * element element. Alternatively, element can be a selector string, which + * will be passed to document.querySelector(). + * + * Examples: `#player`, `.youtube-player`, or a DOM node. + * + * Optionally, provide an options object opts to customize the player. + */ constructor(element: HTMLElement | string, options?: YouTubePlayerOptions); + /** + * This function loads the specified videoId. An example of a videoId is + * 'GKSRyLdjsPA'. + * + * Optionally, specify an autoplay parameter to indicate whether the video + * should begin playing immediately, or wait for a call to player.play(). + * Default is false. + * + * This should be the first function called on a new Player instance. + */ load(videoId: string, autoplay?: boolean): void; - + /** Plays the currently loaded video. */ play(): void; + /** Pauses the currently loaded video. */ pause(): void; + /** + * Stops and cancels loading of the current video.This function should be + * reserved for rare situations when you know that the user will not be + * watching additional video in the player.If your intent is to pause the + * video, you should just call pause().If you want to change the video that + * the player is playing, you can call load() without calling stop() first. + */ stop(): void; + /** + * Seeks to a specified time in the video.If the player is paused when the + * function is called, it will remain paused.If the function is called from + * another state(playing, video cued, etc.), the player will play the + * video.The player will advance to the closest keyframe before that time + * unless the player has already downloaded the portion of the video to + * which the user is seeking. + */ seek(seconds: number): void; - + /** Sets the volume.Accepts an integer between 0 and 100. */ setVolume(volume: number): void; + /** Returns the player's current volume, an integer between 0 and 100. Note that getVolume() will return the volume even if the player is muted. */ getVolume(): number; + /** Mutes the player. */ mute(): void; + /** Unmutes the player. */ unMute(): void; + /** Returns true if the player is muted, false if not. */ isMuted(): boolean; - + /** Sets the size in pixels of the