@itkyk/youtube-controller
v2.1.1
Published
Module for easily incorporating iframe API.
Downloads
77
Maintainers
Readme
@itkyk/youtube-controller
Install
$ npm i @itkyk/youtube-controller
Use this module
import YoutubeController from "@itkyk/youtube-controller";
const initi = async() => {
// start Youtube
const target = document.querySelector("target"); /* <- insert player in this selector*/
const options = {
playerVars: {}
} /* setting YT.Options */
const player = new YoutubeController("videoId", target, options);
await player.onYouTubeIframeAPIReady();
/* ↓ Can use player ↓ */
player.cueVideoById({
videoId: "foobar"
})
player.playVideo();
}
Initial Methods
- onYouTubeIframeAPIReady
- This function is Promise.
- when this function return
Promise
, it mean isonReady
too.
Methods that Player has
- playVideo
- Arguments: none.
- Return: void;
- stopVideo
- Arguments: none.
- Return: void;
- pauseVideo
- Arguments: none.
- Return: void;
- loadVideoById
- Arguments:
- Object
- videoId:string
- startSeconds?:number
- suggestedQuality?:
YT.SuggestedVideoQuality
- Object
- Return: void;
- Arguments:
- loadVideoByUrl
- Arguments:
- Object
- mediaContentUrl:string
- startSeconds?:number
- endSeconds?:number
- suggestedQuality?:
YT.SuggestedVideoQuality
- Object
- Return: void;
- Arguments:
- cueVideoById
- Arguments:
- Object
- videoId: string
- startSeconds?:number
- endSeconds?:number
- suggestedQuality?:
YT.SuggestedVideoQuality
- Object
- Return: void;
- Arguments:
- cueVideoByUrl
- Arguments:
- Object
- mediaContentUrl:string
- startSeconds?:number
- endSeconds?:number
- suggestedQuality?:
YT.SuggestedVideoQuality
- Object
- Return: void;
- Arguments:
- seekTo
- Arguments:
- seconds: number,
- allowSeekAhead:boolean
- Return: void
- Arguments:
- nextVideo
- Arguments: none
- Return none
- previousVideo
- Arguments: none
- Return: void playVideoAt
- Arguments:
- index: number
- Return none
- mute
- Arguments: none
- Return: void
- unMute
- Arguments: none
- Return: void
- isMuted
- Arguments: none
- Return: boolean
- setVolume
- Arguments:
- volume: number
- Return: void
- Arguments:
- getVolume
- Arguments: none
- Return: number
- setSize
- Arguments:
- Object
- width: number
- height: number
- Object
- Return: void
- Arguments:
- getPlaybackRate
- Arguments: none
- Return number
- setPlaybackRate
- Arguments:
- suggestedRate: number
- Return: void
- Arguments:
- getAvailablePlaybackRates
- Arguments: none
- Return: Array
- setLoop
- Arguments:
- loopPlaylists: boolean
- Return: void
- Arguments:
- setShuffle
- Arguments:
- shufflePlaylist: boolean
- Return: void
- Arguments:
- getVideoLoadedFraction
- Arguments: none
- Return: number
- getPlayerState
- Arguments: none
- Return:
YT.PlayerState
- getCurrentTime
- Arguments: none
- Return: number
- getPlaybackQuality
- Arguments: none
- Return:
YT.SuggestedVideoQuality
- setPlaybackQuality
- Arguments:
- suggestedQuality:
YT.SuggestedVideoQuality
- suggestedQuality:
- Return: void
- Arguments:
- getAvailableQualityLevels
- Arguments: none
- Return: Array<
YT.SuggestedVideoQuality
>
- getDuration
- Arguments: none
- Return: number
- getVideoUrl
- Arguments: none
- Return: string
- getVideoEmbedCode
- Arguments: none
- Return: string
- getPlaylist
- Arguments: none
- Return: Array
- getPlaylistIndex
- Arguments: none
- Return: number
- addEventListener
- Arguments:
- event: keyof
YT.PlayerEvent
- listener: (event:
YT.PlayerEvent
)=>void
- event: keyof
- Return: void
- Arguments:
- removeEventListener
- Arguments:
- event: keyof
YT.PlayerEvent
- listener: (event:
YT.PlayerEvent
)=>void
- event: keyof
- Return: void
- Arguments:
- getIframe
- Arguments: none
- Return: HTMLIFrameElement
- destroy
- Arguments: none
- Return: void
- getPlayer
- Argument: none
- Return:
YT.Player
Change Log
update v2.1.1
- Change Types to
@types/youtube
- Change option from
playerVars
toYT.Options
- Change Types to
update v2.0.7
- Fixed overwrite condition of
onYouTubeIframeAPIReady
- Fixed overwrite condition of
update v2.0.6
- Fixed a bug in React that prevented it from working.
update v2.0.5
- Simplified initial setup.
Also, theonYouTubeIframeAPIReady
method has been modified to run correctly.
- Simplified initial setup.