Skip to content

Commit

Permalink
handle onReady option
Browse files Browse the repository at this point in the history
  • Loading branch information
Julie Lala committed Jun 10, 2013
1 parent 394a2a8 commit 83e013a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "OKVideo",
"version": "2.2.0",
"version": "2.2.1",
"main": "./src/okvideo.js",
"dependencies": {
"jquery": ">1.7.2"
Expand Down
1 change: 1 addition & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
annotations: false,
onFinished: function() { console.log('finished') },
unstarted: function() { console.log('unstarted') },
onReady: function() { console.log('onready') },
onPlay: function() { console.log('onplay') },
onPause: function() { console.log('pause') },
buffering: function() { console.log('buffering') },
Expand Down
1 change: 1 addition & 0 deletions demo/vimeo.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
annotations: false,
onFinished: function() { console.log('finished') },
unstarted: function() { console.log('unstarted') },
onReady: function() { console.log('onready') },
onPlay: function() { console.log('onplay') },
onPause: function() { console.log('pause') },
buffering: function() { console.log('buffering') },
Expand Down
6 changes: 1 addition & 5 deletions okvideo.jquery.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "okvideo",
"version": "2.2.0",
"version": "2.2.1",
"title": "okvideo",
"description": "A jQuery Plugin for fullscreen background videos from YouTube or Vimeo.",
"homepage": "https://github.com/okfocus/okvideo",
Expand All @@ -16,10 +16,6 @@
"url": "https://github.com/okfocus"
},
"maintainers": [{
"name": "Jonathan Vingiano",
"url": "https://github.com/jgv"
},
{
"name": "Jules LaPlace",
"url": "https://github.com/julescarbon"
},
Expand Down
24 changes: 15 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Want a YouTube playlist? I got u.
$(function(){
$.okvideo({ playlist: {
list: '[:id]', // a YT playlist id
suggestedQuality: '[:quality]'
suggestedQuality: '[:quality]'
}
});
});
Expand All @@ -47,11 +47,11 @@ OKVideo accepts a number of options. The below will embed a high definition vide
``` js

$(function(){
$.okvideo({
$.okvideo({
source: '[:url]',
volume: 50,
hd: true,
onFinished: function(){
onFinished: function(){
console.log('finished video!')
}
});
Expand All @@ -74,7 +74,7 @@ $(function(){
OKVideo gives you access to all of the YouTube player events. You can listen for all of the available player states: unstarted, ended, playing, paused, buffering, and cued. To listen for them simply pass OKVideo a function to the corresponding option noted below.

## Options
cv

<table>
<tbody>
<tr>
Expand Down Expand Up @@ -135,7 +135,13 @@ cv
<td>unstarted</td>
<td>listen for the "unstarted" event</td>
<td>null</td>
<td>function</td>
<td>function</td>
</tr>
<tr>
<td>onReady</td>
<td>listen for the "ready" event</td>
<td>null</td>
<td>function</td>
</tr>
<tr>
<td>onPlay</td>
Expand All @@ -147,25 +153,25 @@ cv
<td>onPause</td>
<td>listen for the "pause" event</td>
<td>null</td>
<td>function</td>
<td>function</td>
</tr>
<tr>
<td>buffering</td>
<td>listen for the "buffering" event</td>
<td>null</td>
<td>function</td>
<td>function</td>
</tr>
<tr>
<td>cued</td>
<td>listen for the "cued" event</td>
<td>null</td>
<td>function</td>
<td>function</td>
</tr>
<tr>
<td><strong>Playlist</strong></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>playlist.list</td>
Expand Down
9 changes: 7 additions & 2 deletions src/okvideo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* OKVideo by OKFocus v2.2.0
* OKVideo by OKFocus v2.2.1
* http://okfoc.us
*
* Copyright 2012, OKFocus
Expand Down Expand Up @@ -159,6 +159,7 @@ var player, OKEvents, options;
adproof: false,
unstarted: null,
onFinished: null,
onReady: null,
onPlay: null,
onPause: null,
buffering: null,
Expand Down Expand Up @@ -187,6 +188,7 @@ function vimeoPlayerReady() {
}, 2000);

player.addEvent('ready', function () {
OKEvents.v.onReady();
player.api('play');
if (OKEvents.utils.isMobile()) {
// mobile devices cannot listen for play event
Expand Down Expand Up @@ -238,6 +240,7 @@ OKEvents = {
} else {
event.target.playVideo();
}
OKEvents.utils.isFunction(options.onReady) && options.onReady();
},
onStateChange: function(event){
switch(event.data){
Expand Down Expand Up @@ -269,6 +272,9 @@ OKEvents = {
}
},
v: {
onReady: function(){
OKEvents.utils.isFunction(options.onReady) && options.onReady();
},
onPlay: function(){
if (!OKEvents.utils.isMobile()) player.api('api_setVolume', options.volume);
OKEvents.utils.isFunction(options.onPlay) && options.onPlay();
Expand All @@ -285,7 +291,6 @@ OKEvents = {
if (typeof func === 'function'){
return true;
} else {
if (func === 1) func = true;
return false;
}
},
Expand Down

0 comments on commit 83e013a

Please sign in to comment.