YouTube Player API
Complete API reference for the Angular YouTube Player component. Source:/home/daytona/workspace/source/src/youtube-player/youtube-player.ts
Component Inputs
videoId
- Type:
string - Required: Yes (unless using
playerVars.list) - Description: The YouTube video ID to play
width
- Type:
number - Default:
640 - Description: Width of the player in pixels
height
- Type:
number - Default:
390 - Description: Height of the player in pixels
startSeconds
- Type:
number - Description: Start playback at a specific time (in seconds)
endSeconds
- Type:
number - Description: End playback at a specific time (in seconds)
suggestedQuality
- Type:
YT.SuggestedVideoQuality - Description: Suggested video quality
- Values:
'small','medium','large','hd720','hd1080','highres','default'
playerVars
- Type:
YT.PlayerVars - Description: YouTube Player parameters
loadApi
- Type:
boolean - Default:
true - Description: Whether to automatically load the YouTube iframe API
disablePlaceholder
- Type:
boolean - Default:
false - Description: Whether to disable the placeholder and load the API immediately
placeholderImageQuality
- Type:
'low' | 'standard' | 'high' - Default:
'standard' - Description: Quality of the placeholder thumbnail image
placeholderButtonLabel
- Type:
string - Default:
'Play video' - Description: Accessible label for the placeholder play button
disableCookies
- Type:
boolean - Default:
false - Description: Whether to use youtube-nocookie.com instead of youtube.com
Component Outputs (Events)
ready
- Type:
EventEmitter<YT.PlayerEvent> - Description: Fires when the player is ready
stateChange
- Type:
EventEmitter<YT.OnStateChangeEvent> - Description: Fires when the player state changes
playbackQualityChange
- Type:
EventEmitter<YT.OnPlaybackQualityChangeEvent> - Description: Fires when playback quality changes
playbackRateChange
- Type:
EventEmitter<YT.OnPlaybackRateChangeEvent> - Description: Fires when playback rate changes
error
- Type:
EventEmitter<YT.OnErrorEvent> - Description: Fires when an error occurs
apiChange
- Type:
EventEmitter<YT.PlayerEvent> - Description: Fires when the player’s API changes
Component Methods
Access these methods usingViewChild or viewChild:
Playback Controls
playVideo()- Play the videopauseVideo()- Pause the videostopVideo()- Stop the videoseekTo(seconds: number, allowSeekAhead: boolean)- Seek to a specific timemute()- Mute the playerunMute()- Unmute the player
Player State
getPlayerState()- Get current player stategetCurrentTime()- Get current playback time in secondsgetDuration()- Get video duration in secondsgetVolume()- Get volume level (0-100)getPlaybackRate()- Get playback speedgetAvailablePlaybackRates()- Get available playback speeds
Player Settings
setVolume(volume: number)- Set volume (0-100)setPlaybackRate(rate: number)- Set playback speedsetSize(width: number, height: number)- Resize the player
Video Info
getVideoUrl()- Get video URLgetVideoEmbedCode()- Get embed codegetPlaylist()- Get playlist (if playing a playlist)getPlaylistIndex()- Get current position in playlist
Common PlayerVars
Here are commonly usedplayerVars options: