@capgo/capacitor-youtube-player
YouTube Player Plugin interface for Capacitor. Provides methods to control YouTube video playback in your app.
Overview
Section titled “Overview”YouTube Player Plugin interface for Capacitor. Provides methods to control YouTube video playback in your app.
Core Capabilities
Section titled “Core Capabilities”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).
Public API
Section titled “Public API”| Method | Description |
|---|---|
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). |
pauseVideo | Pause the currently playing video. Final player state will be PAUSED (2), unless already ENDED (0). |
seekTo | Seek to a specific time in the video. If player is paused, it remains paused. If playing, continues playing. |
loadVideoById | Load and play a video by its YouTube ID. |
cueVideoById | Cue a video by ID without playing it. Loads thumbnail and prepares player, but doesn’t request video until playVideo() called. |
loadVideoByUrl | Load and play a video by its full URL. |
cueVideoByUrl | Cue a video by URL without playing it. |
cuePlaylist | Cue a playlist without playing it. Loads playlist and prepares first video. |
loadPlaylist | Load and play a playlist. |
nextVideo | Play the next video in the playlist. |
previousVideo | Play the previous video in the playlist. |
playVideoAt | Play a specific video in the playlist by index. |
mute | Mute the player audio. |
unMute | Unmute the player audio. |
isMuted | Check if the player is currently muted. |
setVolume | Set the player volume level. |
getVolume | Get the current player volume level. Returns volume even if player is muted. |
setSize | Set the player dimensions in pixels. |
getPlaybackRate | Get the current playback rate. |
setPlaybackRate | Set the playback speed. |
getAvailablePlaybackRates | Get list of available playback rates for current video. |
setLoop | Enable or disable playlist looping. When enabled, playlist will restart from beginning after last video. |
setShuffle | Enable or disable playlist shuffle. |
getVideoLoadedFraction | Get the fraction of the video that has been buffered. More reliable than deprecated getVideoBytesLoaded/getVideoBytesTotal. |
getPlayerState | Get the current state of the player. |
getAllPlayersEventsState | Get event states for all active players. Useful for tracking multiple player instances. |
getCurrentTime | Get the current playback position in seconds. |
toggleFullScreen | Toggle fullscreen mode on or off. |
getPlaybackQuality | Get the current playback quality. |
setPlaybackQuality | Set the suggested playback quality. Actual quality may differ based on network conditions. |
getAvailableQualityLevels | Get list of available quality levels for current video. |
getDuration | Get the duration of the current video in seconds. |
getVideoUrl | Get the YouTube.com URL for the current video. |
getVideoEmbedCode | Get the embed code for the current video. Returns HTML iframe embed code. |
getPlaylist | Get array of video IDs in the current playlist. |
getPlaylistIndex | Get the index of the currently playing video in the playlist. |
getIframe | Get the iframe DOM element for the player. Web platform only. |
addEventListener | Add an event listener to the player. Web platform only. |
removeEventListener | Remove an event listener from the player. Web platform only. |
getPluginVersion | Get the plugin version number. Returns platform-specific version information. |
Source Of Truth
Section titled “Source Of Truth”This reference is synced from src/definitions.ts in capacitor-youtube-player.