Skip to content

Commit

Permalink
Merge pull request #67 from nirvanatikku/develop
Browse files Browse the repository at this point in the history
2.1.0
  • Loading branch information
nirvanatikku authored Dec 3, 2016
2 parents a9cc8dc + c3bf4e8 commit b30c3bf
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 28 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

__v2.1.0 - Dec 2, 2016__

* Exposed default settings `$.tubeplayer.defaults.settings`
* New player event: "onPlayerLoaded", _complementing_ $.tubeplayer.defaults.afterReady

__v2.0.0 - Dec 2, 2016__

* Removed code to handle flash player (due to deprecation); instead - uses iframe player exclusively
Expand Down
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,15 @@ In your web page:

```html
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//raw.githubusercontent.com/nirvanatikku/jQuery-TubePlayer-Plugin/master/dist/jquery.tubeplayer.min.js"></script>
<script src="jquery.tubeplayer.js"></script>
<div id='youtube-video-player'></div>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#youtube-video-player").tubeplayer({
width: 600, // the width of the player
height: 450, // the height of the player
initialVideo: "kOkQ4T5WO9E", // the video that is loaded into the player
onPlay: function(id){}, // after the play method is called
onPause: function(){}, // after the pause method is called
onStop: function(){}, // after the player is stopped
onSeek: function(time){}, // after the video has been seeked to a defined point
onMute: function(){}, // after the player is muted
onUnMute: function(){} // after the player is unmuted
initialVideo: "kOkQ4T5WO9E",
onPlayerLoaded: function(){
console.log(this.tubeplayer("data"));
},
});
});
</script>
Expand All @@ -39,7 +34,7 @@ jQuery(document).ready(function(){
### TubePlayer Plugin Defaults

```javascript
{
$.tubeplayer.defaults.settings = {

// Plugin init params
width: 480, // the width of the player
Expand Down Expand Up @@ -74,6 +69,7 @@ jQuery(document).ready(function(){
onPlayerPaused: function(){}, // player returns a state of paused
onPlayerBuffering: function(){}, // player returns a state of buffering
onPlayerCued: function(){}, // player returns a state of cued
onPlayerLoaded: function(){}, // player is initially loaded and attached to the DOM
onQualityChange: function(quality){}, // player quality changes
onRateChange: function(rate){}, // player rate changes

Expand Down Expand Up @@ -107,6 +103,7 @@ onPlayerPlaying
onPlayerPaused
onPlayerBuffering
onPlayerCued
onPlayerLoaded
onQualityChange
onRateChange
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery-tubeplayer-plugin",
"version": "2.0.0",
"version": "2.1.0",
"homepage": "https://github.com/nirvanatikku/jQuery-TubePlayer-Plugin",
"authors": [
"Nirvana Tikku <[email protected]>"
Expand Down
16 changes: 10 additions & 6 deletions dist/jquery.tubeplayer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! jQuery TubePlayer - Simplified YouTube Player Management - v2.0.0-beta - 2016-12-02
/*! jQuery TubePlayer - Simplified YouTube Player Management - v2.1.0 - 2016-12-02
* https://github.com/nirvanatikku/jQuery-TubePlayer-Plugin
* Copyright (c) 2016 Nirvana Tikku; Licensed MIT */
(function($) {
Expand Down Expand Up @@ -123,7 +123,8 @@
playing: {},
paused: {},
buffering: {},
cued: {}
cued: {},
loaded: {}
},
onErr: {
defaultError: {},
Expand All @@ -138,7 +139,7 @@
* plugin to work without providing any parameters. They
* are merged with the users options.
*/
var defaults = {
$.tubeplayer.defaults.settings = {

// public facing
width: 480,
Expand Down Expand Up @@ -169,6 +170,7 @@
onUnMute: function() {},

// functions called when events are triggered from the youtube player itself
onPlayerLoaded: function(){},
onPlayerUnstarted: function() {},
onPlayerEnded: function() {},
onPlayerPlaying: function() {},
Expand Down Expand Up @@ -225,7 +227,7 @@
'id' : ids ? ids : ''
});
$this.replaceWith(newDiv);
var new_input = $.extend({}, defaults, settings, input);
var new_input = $.extend({}, $.tubeplayer.defaults.settings, settings, input);
TP.init(newDiv, new_input);
}
} else {
Expand Down Expand Up @@ -280,7 +282,7 @@
if ($player.hasClass(TUBEPLAYER_CLASS)) {
return $player;
}
var o = $.extend({}, defaults, opts);
var o = $.extend({}, $.tubeplayer.defaults.settings, opts);
o.playerID += "-" + guid();
$player.addClass(TUBEPLAYER_CLASS).data(OPTS, o);
for (var event in PlayerEvents){
Expand Down Expand Up @@ -342,6 +344,7 @@
'onReady': function(evt) {
TP.ytplayers[o.playerID] = evt.target;
var $player = $(evt.target.getIframe()).parents("." + TUBEPLAYER_CLASS);
$player.tubeplayer('opts').onPlayerLoaded.call($player);
$.tubeplayer.defaults.afterReady($player);
},
'onPlaybackQualityChange': $.tubeplayer.defaults.qualityChange(o.playerID),
Expand Down Expand Up @@ -385,6 +388,7 @@
dp.paused[ID] = o.onPlayerPaused;
dp.buffering[ID] = o.onPlayerBuffering;
dp.cued[ID] = o.onPlayerCued;
dp.loaded[ID] = o.onPlayerLoaded;

// default onQualityChange
d.onQualityChange[ID] = o.onQualityChange;
Expand Down Expand Up @@ -592,7 +596,7 @@
delete TP.ytplayers[p.opts.playerID];
// cleanup callback handler references..
var d = $.tubeplayer.defaults;
var events = ['unstarted', 'ended', 'playing', 'paused', 'buffering', 'cued'];
var events = ['unstarted', 'ended', 'playing', 'paused', 'buffering', 'cued', 'loaded'];
$.each(events, function(i, event) {
delete d.onPlayer[event][p.opts.playerID];
});
Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.tubeplayer.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "jquery-tubeplayer-plugin",
"title": "jQuery TubePlayer Plugin",
"description": "Simplified management of embedded YouTube players",
"version": "2.0.0",
"version": "2.1.0",
"homepage": "https://github.com/nirvanatikku/jQuery-TubePlayer-Plugin",
"bugs": "https://github.com/nirvanatikku/jQuery-TubePlayer-Plugin/issues",
"author": {
Expand Down
14 changes: 9 additions & 5 deletions src/tubeplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@
playing: {},
paused: {},
buffering: {},
cued: {}
cued: {},
loaded: {}
},
onErr: {
defaultError: {},
Expand All @@ -135,7 +136,7 @@
* plugin to work without providing any parameters. They
* are merged with the users options.
*/
var defaults = {
$.tubeplayer.defaults.settings = {

// public facing
width: 480,
Expand Down Expand Up @@ -166,6 +167,7 @@
onUnMute: function() {},

// functions called when events are triggered from the youtube player itself
onPlayerLoaded: function(){},
onPlayerUnstarted: function() {},
onPlayerEnded: function() {},
onPlayerPlaying: function() {},
Expand Down Expand Up @@ -222,7 +224,7 @@
'id' : ids ? ids : ''
});
$this.replaceWith(newDiv);
var new_input = $.extend({}, defaults, settings, input);
var new_input = $.extend({}, $.tubeplayer.defaults.settings, settings, input);
TP.init(newDiv, new_input);
}
} else {
Expand Down Expand Up @@ -277,7 +279,7 @@
if ($player.hasClass(TUBEPLAYER_CLASS)) {
return $player;
}
var o = $.extend({}, defaults, opts);
var o = $.extend({}, $.tubeplayer.defaults.settings, opts);
o.playerID += "-" + guid();
$player.addClass(TUBEPLAYER_CLASS).data(OPTS, o);
for (var event in PlayerEvents){
Expand Down Expand Up @@ -339,6 +341,7 @@
'onReady': function(evt) {
TP.ytplayers[o.playerID] = evt.target;
var $player = $(evt.target.getIframe()).parents("." + TUBEPLAYER_CLASS);
$player.tubeplayer('opts').onPlayerLoaded.call($player);
$.tubeplayer.defaults.afterReady($player);
},
'onPlaybackQualityChange': $.tubeplayer.defaults.qualityChange(o.playerID),
Expand Down Expand Up @@ -382,6 +385,7 @@
dp.paused[ID] = o.onPlayerPaused;
dp.buffering[ID] = o.onPlayerBuffering;
dp.cued[ID] = o.onPlayerCued;
dp.loaded[ID] = o.onPlayerLoaded;

// default onQualityChange
d.onQualityChange[ID] = o.onQualityChange;
Expand Down Expand Up @@ -589,7 +593,7 @@
delete TP.ytplayers[p.opts.playerID];
// cleanup callback handler references..
var d = $.tubeplayer.defaults;
var events = ['unstarted', 'ended', 'playing', 'paused', 'buffering', 'cued'];
var events = ['unstarted', 'ended', 'playing', 'paused', 'buffering', 'cued', 'loaded'];
$.each(events, function(i, event) {
delete d.onPlayer[event][p.opts.playerID];
});
Expand Down
5 changes: 4 additions & 1 deletion test_console/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<ul class="nav navbar-nav">
<li class="active"><a href="#"><strong>jQuery YouTube TubePlayer Plugin V2.0</strong></a></li>
<li><a href="../test/tubeplayer.html">Unit Tests</a></li>
<li><a href="http://www.tikku.com/jQuery-youtube-tubeplayer-plugin/api">TubePlayer API</a></li>
<li><a href="http://www.tikku.com/jQuery-youtube-tubeplayer-plugin">TubePlayer API</a></li>
<li><a href="https://developers.google.com/youtube/iframe_api_reference">YouTube Player API</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
Expand Down Expand Up @@ -483,6 +483,9 @@ <h3>Player Activity Callbacks</h3>
onPlayerCued: function(){
printPlayerUpdate("CUED (onPlayerCued)");
},
onPlayerLoaded: function(){
printPlayerUpdate("LOADED (onPlayerLoaded)");
},
onQualityChange: function(qual){
printPlayerUpdate("QUALITY CHANGED: " + qual +" (onQualityChange)");
},
Expand Down
2 changes: 1 addition & 1 deletion tubeplayer.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "tubeplayer",
"title": "jQuery TubePlayer - Simplified YouTube Player Management",
"description": "Simplified management of embedded YouTube players",
"version": "2.0.0",
"version": "2.1.0",
"homepage": "https://github.com/nirvanatikku/jQuery-TubePlayer-Plugin",
"bugs": "https://github.com/nirvanatikku/jQuery-TubePlayer-Plugin/issues",
"author": {
Expand Down

0 comments on commit b30c3bf

Please sign in to comment.