Skip to content
This repository has been archived by the owner on Dec 12, 2019. It is now read-only.

Wrapper for the YouTube Iframe API which simplifies event handling and provides responsiveness.

Notifications You must be signed in to change notification settings

mynewsdesk/deprecated-mnd-youtube-iframe-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MND YouTube Iframe API

Wrapper for the YouTube Iframe API which simplifies event handling and provides responsiveness.

Dependencies

None.

Examples

var player = new YouTubeIframePlayer('video-container', 'wRnSnfiUI54');

// Optional: overwrite this method like below if you wish to control when the player is inserted.
// By default the player will be inserted when the YouTube API is ready.
onYouTubeIframeAPIReady = function() {
  player.insertPlayer();
}

// Hook up to an event.
player.on('ended', function(data) {
  alert("Thanks for watching");
});

Events

All events forward the data from the YouTube API. The error event provides error code and message (data.code and data.message).

  • ready
  • error
  • playbackRateChange
  • playbackQualityChange
  • apiChange
  • unstarted
  • ended
  • playing
  • paused
  • buffering
  • cued

Constructor arguments

Name Type Description Default value
playerContainerId String The id of the element to be replaced by the iframe. undefined
videoId String YouTube video id. undefined
width Integer Initial width. 560
height Integer Initial height. 315
playerVars Object Options for YouTube iframe. {}
responsiveIframe Boolean Adjust iframe size by parent container. false
initialResize Boolean Initially adjust the iframe to its parent. true
resizeTimeout Integer How long to wait between resizes. 100

Developers

You can run the tests on the console:

npm test

Or in your favorite web browser:

npm run open-tests

About

Wrapper for the YouTube Iframe API which simplifies event handling and provides responsiveness.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published