An open API service indexing awesome lists of open source software.

https://github.com/b13/js-youtube


https://github.com/b13/js-youtube

Last synced: 8 days ago
JSON representation

Awesome Lists containing this project

README

          

js-youtube
=================

Module to load youtube iFrame API with requireJS and init the youtube player.

# requireJS config

```js
var require = {
paths: {
'jquery' : 'path/to/jquery'
, 'youTube' : 'path/to/youtube'
, 'youTubeIFrameAPI' : 'https://www.youtube.com/iframe_api?noext'
}
, shim: {
"youTubeIFrameAPI": {
exports: 'YT'
}
}
};
```

# Basic usage

```js
require(['youTube'], function(youTube) {

// do youtube setup and init player
var player = new youTube({
id : id
, youTubeId : youTubeId
, height : 400
, width : 600
, onPlaying : function() {}
, onPaused : function() {}
, onEnded : function() {}
});

// start video
player.play();

// pause video
player.pause();

// stop video
player.stop();

// get youtube player object
var ytObj = player.getYouTubePlayer();
});
```