Skip to content

@capgo/capacitor-youtube-player

YouTube Player Plugin interface for Capacitor. Provides methods to control YouTube video playback in your app.

YouTube Player Plugin interface for Capacitor. Provides methods to control YouTube video playback in your app.

  • initialize - Initialize a new YouTube player instance.
  • destroy - Destroy a player instance and free resources.
  • stopVideo - Stop video playback and cancel loading. Use this sparingly - pauseVideo() is usually preferred.
  • playVideo - Play the currently cued or loaded video. Final player state will be PLAYING (1).
MethodDescription
initializeInitialize a new YouTube player instance.
destroyDestroy a player instance and free resources.
stopVideoStop video playback and cancel loading. Use this sparingly - pauseVideo() is usually preferred.
playVideoPlay the currently cued or loaded video. Final player state will be PLAYING (1).
pauseVideoPause the currently playing video. Final player state will be PAUSED (2), unless already ENDED (0).
seekToSeek to a specific time in the video. If player is paused, it remains paused. If playing, continues playing.
loadVideoByIdLoad and play a video by its YouTube ID.
cueVideoByIdCue a video by ID without playing it. Loads thumbnail and prepares player, but doesn’t request video until playVideo() called.
loadVideoByUrlLoad and play a video by its full URL.
cueVideoByUrlCue a video by URL without playing it.
cuePlaylistCue a playlist without playing it. Loads playlist and prepares first video.
loadPlaylistLoad and play a playlist.
nextVideoPlay the next video in the playlist.
previousVideoPlay the previous video in the playlist.
playVideoAtPlay a specific video in the playlist by index.
muteMute the player audio.
unMuteUnmute the player audio.
isMutedCheck if the player is currently muted.
setVolumeSet the player volume level.
getVolumeGet the current player volume level. Returns volume even if player is muted.
setSizeSet the player dimensions in pixels.
getPlaybackRateGet the current playback rate.
setPlaybackRateSet the playback speed.
getAvailablePlaybackRatesGet list of available playback rates for current video.
setLoopEnable or disable playlist looping. When enabled, playlist will restart from beginning after last video.
setShuffleEnable or disable playlist shuffle.
getVideoLoadedFractionGet the fraction of the video that has been buffered. More reliable than deprecated getVideoBytesLoaded/getVideoBytesTotal.
getPlayerStateGet the current state of the player.
getAllPlayersEventsStateGet event states for all active players. Useful for tracking multiple player instances.
getCurrentTimeGet the current playback position in seconds.
toggleFullScreenToggle fullscreen mode on or off.
getPlaybackQualityGet the current playback quality.
setPlaybackQualitySet the suggested playback quality. Actual quality may differ based on network conditions.
getAvailableQualityLevelsGet list of available quality levels for current video.
getDurationGet the duration of the current video in seconds.
getVideoUrlGet the YouTube.com URL for the current video.
getVideoEmbedCodeGet the embed code for the current video. Returns HTML iframe embed code.
getPlaylistGet array of video IDs in the current playlist.
getPlaylistIndexGet the index of the currently playing video in the playlist.
getIframeGet the iframe DOM element for the player. Web platform only.
addEventListenerAdd an event listener to the player. Web platform only.
removeEventListenerRemove an event listener from the player. Web platform only.
getPluginVersionGet the plugin version number. Returns platform-specific version information.

This reference is synced from src/definitions.ts in capacitor-youtube-player.