youtube-embed
Documentation / interface/youtube-embed
Interface​
embedYoutubePlayer()​
function embedYoutubePlayer(): YouTubePlayer;
Defined in: interface/youtube-embed.js:68
Creates video player wrapping YouTube IFrame Player API in a div element with the specified ID.
Returns​
An object containing the YouTube API functionality.
Example​
// <div id="player"></div>
const YT = embedYoutubePlayer();
new YT.Player('player', {
height: '360',
width: '640',
videoId: 'dQw4w9WgXcQ',
events: {
'onReady': onPlayerReady,
'onStateChange': null,
'onTimeChange': onTimeChange,
}
});
function onPlayerReady(event) {
event.target.playVideo();
}
function onTimeChange(time) {
console.log(time)
}
Other​
YouTubePlayer​
Defined in: interface/youtube-embed.js:2
Properties​
Property | Type | Description | Defined in |
---|---|---|---|
| Adds an event listener. | interface/youtube-embed.js:35 | |
| Cues a playlist. | interface/youtube-embed.js:8 | |
| Cues a specified video. | interface/youtube-embed.js:4 | |
| Cues a video by URL. | interface/youtube-embed.js:6 | |
| Destroys the player instance. | interface/youtube-embed.js:38 | |
| Gets available playback rates. | interface/youtube-embed.js:24 | |
| Gets the current playback time. | interface/youtube-embed.js:29 | |
| Gets the video duration. | interface/youtube-embed.js:30 | |
| Gets the player iframe element. | interface/youtube-embed.js:37 | |
| Gets the playback rate. | interface/youtube-embed.js:22 | |
| Gets the current player state. | interface/youtube-embed.js:28 | |
| Gets the current playlist. | interface/youtube-embed.js:33 | |
| Gets the index of the current playlist item. | interface/youtube-embed.js:34 | |
| Gets the embed code for the current video. | interface/youtube-embed.js:32 | |
| Gets the fraction of the video loaded. | interface/youtube-embed.js:27 | |
| Gets the URL of the current video. | interface/youtube-embed.js:31 | |
| Gets the player volume. | interface/youtube-embed.js:20 | |
| Checks if the player is muted. | interface/youtube-embed.js:18 | |
| Loads a playlist. | interface/youtube-embed.js:7 | |
| Loads a specified video. | interface/youtube-embed.js:3 | |
| Loads a video by URL. | interface/youtube-embed.js:5 | |
| Mutes the player. | interface/youtube-embed.js:16 | |
| Plays the next video in the playlist. | interface/youtube-embed.js:13 | |
| Pauses the currently playing video. | interface/youtube-embed.js:10 | |
| Plays the currently loaded video. | interface/youtube-embed.js:9 | |
| Plays a specific video in the playlist. | interface/youtube-embed.js:15 | |
| Plays the previous video in the playlist. | interface/youtube-embed.js:14 | |
| Removes an event listener. | interface/youtube-embed.js:36 | |
| Seeks to a specified time in the video. | interface/youtube-embed.js:12 | |
| Sets whether the player should loop playlists. | interface/youtube-embed.js:25 | |
| Sets the playback rate. | interface/youtube-embed.js:23 | |
| Sets whether playlists should be shuffled. | interface/youtube-embed.js:26 | |
| Sets the player size. | interface/youtube-embed.js:21 | |
| Sets the player volume. | interface/youtube-embed.js:19 | |
| Stops the currently playing video. | interface/youtube-embed.js:11 | |
| Unmutes the player. | interface/youtube-embed.js:17 |