new YouTube()
Members
(static, constant) HisPlayerEvent :string
YouTube HISPlayer event types.
Properties:
Name | Value | Type | Description |
---|---|---|---|
LICENSE_ERROR |
licenseError | string | |
STATE_CHANGE |
stateChange | string | The event has the detail field with the PLAYER_STATES. |
ERROR |
error | string | The event has the detail field with the YouTube error. |
VIDEO_TRACK_CHANGE |
videoTrackChange | string | The event has the detail field with the new quality. |
(static, constant) PLAYER_STATES :string
YouTube HISPlayer states.
Properties:
Name | Value | Type | Description |
---|---|---|---|
NONE |
None | string | |
CONTENT_REQUESTED |
ContentRequested | string | |
READY |
Ready | string | |
BUFFERING |
Buffering | string | |
PLAYING |
Playing | string | |
PAUSED |
Paused | string | |
ENDED |
Ended | string |
Methods
addEventListener(type, listener)
Add an event listener to this object.
Parameters:
Name | Type | Description |
---|---|---|
type |
string | The event type to listen for. |
listener |
EventListener | function | The callback or listener object to invoke. |
destroy()
Destroy the YouTube instance.
getCurrentTime() → {number}
Returns the YouTube video's current time.
getDuration() → {number}
Returns the duration of the YouTube video.
getPlaybackRate() → {number}
Returns the current YouTube video rate.
getPlayerContainerDiv() → {Element}
Returns the div Element where the player is displayed.
getVideoUrl() → (nullable) {string}
Gets the Youtube's URL.
getVolume() → {number}
Returns the current volume. Valid values are contained between 0.0 and 1.0.
init(userConfig)
Create YouTube player.
Parameters:
Name | Type | Description |
---|---|---|
userConfig |
YouTubeConfig |
isMuted() → {boolean}
Returns true if the current YouTube video is muted.
isPaused() → {boolean}
Returns true if the YouTube video is paused.
listenToAllEvents(listener)
Add an event listener to this object that is invoked for all events types the object fires.
Parameters:
Name | Type | Description |
---|---|---|
listener |
EventListener | function | The callback or listener object to invoke. |
loadSource(url, resumePositionopt, autoplayopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
string | ||
resumePosition |
number |
<optional> |
|
autoplay |
boolean |
<optional> |
pause()
Pause the current YouTube video.
play()
Play the current YouTube video if it is loaded and paused.
removeEventListener(type, listener)
Remove an event listener from this object.
Parameters:
Name | Type | Description |
---|---|---|
type |
string | The event type for which you wish to remove a listener. |
listener |
EventListener | function | The callback or listener object to remove. |
seek(timePosition)
Seek the playhead to the position provided.
Parameters:
Name | Type | Description |
---|---|---|
timePosition |
number |
setMute(muted)
Set the mute for the current playback.
Parameters:
Name | Type | Description |
---|---|---|
muted |
boolean |
setVolume(volume)
Set the volume for the current playback.
Parameters:
Name | Type | Description |
---|---|---|
volume |
number | The volume to set, from 0 (muted) to 1 (loudest). |