1.0.1 • Published 6 years ago
get-youtube-instance v1.0.1
getYoutubeInstance
getYoutubeInstance is a minimalist script to easily get the Youtube instance from a player added with Youtube iframe API.
The function accept HTML element (iframe) or HTML element id. The YouTube instance then allows you to manipulate the player.
Installation
The plugin is available as the get-youtube-instance package name on npm and Github.
npm i --save-dev get-youtube-instanceyarn add --dev get-youtube-instanceEnvironment
getYoutubeInstance was built for Node.js >=8.11.2.
Usage
Usage with HTML element
The following example returns the Youtube instance for the current player from iframe element.
<iframe id="player-yt" src="https://www.youtube.com/embed/aqz-KE-bpKQ"></iframe>getYoutubeInstance(document.querySelector('#player-yt'));Usage with HTML id
The following example returns the Youtube instance for the current player from iframe id.
<iframe id="player-yt" src="https://www.youtube.com/embed/aqz-KE-bpKQ"></iframe>getYoutubeInstance('player-yt');Parameters
option
HTMLElement || string
Tells to the function the target element or the id of the target element.
Licence
getYoutubeInstance is licensed under the MIT License.
Created with ♥ by @yoriiis.