Skip to main content

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​

YouTubePlayer

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​

PropertyTypeDescriptionDefined in

addEventListener

Function

Adds an event listener.

interface/youtube-embed.js:35

cuePlaylist

Function

Cues a playlist.

interface/youtube-embed.js:8

cueVideoById

Function

Cues a specified video.

interface/youtube-embed.js:4

cueVideoByUrl

Function

Cues a video by URL.

interface/youtube-embed.js:6

destroy

Function

Destroys the player instance.

interface/youtube-embed.js:38

getAvailablePlaybackRates

Function

Gets available playback rates.

interface/youtube-embed.js:24

getCurrentTime

Function

Gets the current playback time.

interface/youtube-embed.js:29

getDuration

Function

Gets the video duration.

interface/youtube-embed.js:30

getIframe

Function

Gets the player iframe element.

interface/youtube-embed.js:37

getPlaybackRate

Function

Gets the playback rate.

interface/youtube-embed.js:22

getPlayerState

Function

Gets the current player state.

interface/youtube-embed.js:28

getPlaylist

Function

Gets the current playlist.

interface/youtube-embed.js:33

getPlaylistIndex

Function

Gets the index of the current playlist item.

interface/youtube-embed.js:34

getVideoEmbedCode

Function

Gets the embed code for the current video.

interface/youtube-embed.js:32

getVideoLoadedFraction

Function

Gets the fraction of the video loaded.

interface/youtube-embed.js:27

getVideoUrl

Function

Gets the URL of the current video.

interface/youtube-embed.js:31

getVolume

Function

Gets the player volume.

interface/youtube-embed.js:20

isMuted

Function

Checks if the player is muted.

interface/youtube-embed.js:18

loadPlaylist

Function

Loads a playlist.

interface/youtube-embed.js:7

loadVideoById

Function

Loads a specified video.

interface/youtube-embed.js:3

loadVideoByUrl

Function

Loads a video by URL.

interface/youtube-embed.js:5

mute

Function

Mutes the player.

interface/youtube-embed.js:16

nextVideo

Function

Plays the next video in the playlist.

interface/youtube-embed.js:13

pauseVideo

Function

Pauses the currently playing video.

interface/youtube-embed.js:10

playVideo

Function

Plays the currently loaded video.

interface/youtube-embed.js:9

playVideoAt

Function

Plays a specific video in the playlist.

interface/youtube-embed.js:15

previousVideo

Function

Plays the previous video in the playlist.

interface/youtube-embed.js:14

removeEventListener

Function

Removes an event listener.

interface/youtube-embed.js:36

seekTo

Function

Seeks to a specified time in the video.

interface/youtube-embed.js:12

setLoop

Function

Sets whether the player should loop playlists.

interface/youtube-embed.js:25

setPlaybackRate

Function

Sets the playback rate.

interface/youtube-embed.js:23

setShuffle

Function

Sets whether playlists should be shuffled.

interface/youtube-embed.js:26

setSize

Function

Sets the player size.

interface/youtube-embed.js:21

setVolume

Function

Sets the player volume.

interface/youtube-embed.js:19

stopVideo

Function

Stops the currently playing video.

interface/youtube-embed.js:11

unMute

Function

Unmutes the player.

interface/youtube-embed.js:17