Youtube-Player
Android Device | Android Emulator | iOS Device | iOS Simulator |
✅ | ✅ | ✅ | ✅ |
Installing
Configuration
Core
IMPORTANT Ensure you've included `xmlns:ui="@triniwiz/nativescript-youtubeplayer"` on the Page element
Angular
Vue
React
Svelte
API
Properties
Property | Default | Type | iOS | Android | Notes |
videoId | undefined | string | ✅ | ✅ | The YouTube video ID that identifies the video that the player will load. |
showRelatedVideos | true | boolean | ✅ | ✅ | https://developers.google.com/youtube/player_parameters#rel |
showYoutubeLogo | true | boolean | ✅ | ✅ | https://developers.google.com/youtube/player_parameters#modestbranding |
loop | false | boolean | ✅ | ✅ | https://developers.google.com/youtube/player_parameters#loop |
autoPlay | false | boolean | ✅ | ✅ | Auto play video once it's ready. |
showFullScreenToggle | true | boolean | ✅ | ✅ | https://developers.google.com/youtube/player_parameters#fs |
controls | true | boolean | ✅ | ✅ | https://developers.google.com/youtube/player_parameters#controls |
playsInLine | true | boolean | ✅ | ✅ | https://developers.google.com/youtube/player_parameters#playsinline |
duration | 0 | number | ✅ | ✅ | Current video duration. |
Static Properties
Property | Value | Type | iOS | Android | Notes |
onReadyEvent | "ready" | string | ✅ | ✅ | |
onErrorEvent | "error" | string | ✅ | ✅ | |
onCurrentTimeEvent | "currentTime" | string | ✅ | ✅ | |
onApiReadyEvent | "apiReady" | sting | ✅ | ✅ | |
onStateChangeEvent | "stateChange" | string | ✅ | ✅ | |
onFullScreenEvent | "fullScreen" | string | ✅ | ✅ | |
onPlayBackQualityEvent | "playBackQuality" | string | ✅ | ✅ | |
onPlaybackRateChangeEvent | "playbackRate" | sting | ✅ | ✅ | |
Methods
Method | Type |
on(event: 'ready', callback: (args: any) => void, thisArg?: any); | void |
on(event: 'error', callback: (args: any) => void, thisArg?: any); | void |
on(event: 'currentTime', callback: (args: any) => void, thisArg?: any); | void |
on(event: 'apiReady', callback: (args: any) => void, thisArg?: any); | void |
on(event: 'stateChange', callback: (args: any) => void, thisArg?: any); | void |
on(event: 'fullScreen', callback: (args: any) => void, thisArg?: any); | void |
on(event: 'playBackQuality', callback: (args: any) => void, thisArg?: any); | void |
on(event: 'playbackRate', callback: (args: any) => void, thisArg?: any); | void |
play(); | void |
playById(id: string); | void |
playByUrl(url: string); | void |
cueVideoById(id: string); | void |
cueVideoByUrl(url: string); | void |
pause(); | void |
next(); | void |
previous(); | void |
mute(); | void |
unmute(); | void |
seekTo(value: number); | void |
setVolume(value: number); | void |
stop(); | void |
Enums
YoutubePlayerState
Members | Value |
Unstarted | -1 |
Ended | 0 |
Playing | 1 |
Paused | 2 |
Buffering | 3 |
Cued | 5 |
YoutubePlayerQuality
Members | Value |
Small | "small" |
Medium | "medium" |
Large | "large" |
HD720 | "hd720" |
HD1080 | "hd1080" |
HighRes | "highres" |
YoutubePlayerErrors
Members | Value |
InvalidParam | "The request contains an invalid parameter value" |
HTML5Error | "The requested content cannot be played in an HTML5 player" |
VideoNotFound | "The video requested was not found" |
NotEmbeddable | "The owner of the requested video does not allow it to be played in embedded players." |
YoutubePlayerInternalErrors
Members | Value |
InvalidParamErrorCode | 2 |
HTML5ErrorCode | 5 |
VideoNotFoundErrorCode | 100 |
NotEmbeddableErrorCode | 101 |
CannotFindVideoErrorCode | 105 |
SameAsNotEmbeddableErrorCode | 150 |