Skip to content

Commit 544ca31

Browse files
author
Julie Lala
committed
[2.3.1] option to autoplay
1 parent e2080dc commit 544ca31

8 files changed

+43
-23
lines changed

Gruntfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = function(grunt) {
1414
},
1515
uglify: {
1616
options: {
17-
banner: '/* okvideo by okfocus ~ v2.3.0 ~ https://github.com/okfocus/okvideo */\n'
17+
banner: '/* okvideo by okfocus ~ v2.3.1 ~ https://github.com/okfocus/okvideo */\n'
1818
},
1919
build: {
2020
src: 'src/okvideo.concat.js',

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "okvideo",
3-
"version": "2.2.2",
3+
"version": "2.3.1",
44
"homepage": "http://okfoc.us/okvideo",
55
"authors": [
66
"OKFocus"

component.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "OKVideo",
3-
"version": "2.2.2",
3+
"version": "2.3.1",
44
"main": "./src/okvideo.js",
55
"dependencies": {
66
"jquery": ">1.7.2"

demo/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ <h2>OKFocus Video</h2>
154154
</tbody>
155155
</table>
156156
</pre>
157-
'Checkout' the <a href="https://github.com/okfocus/okvideo">GitHub repo</a> for this, also checkout our <a href="http://okfoc.us/#labs">other awesome codez!
157+
'Checkout' the <a href="https://github.com/okfocus/okvideo">GitHub repo</a> for this, also checkout our <a href="http://okfoc.us/">other awesome codez!
158158
</div>
159159
</body>
160160
</html>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "okvideo",
3-
"version": "2.2.2",
3+
"version": "2.3.1",
44
"devDependencies": {
55
"grunt": "~0.4.1",
66
"grunt-contrib-concat": "~0.3.0",

readme.md

+12
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,18 @@ OKVideo gives you access to all of the YouTube player events. You can listen for
125125
<td>true</td>
126126
<td>boolean</td>
127127
</tr>
128+
<tr>
129+
<td>autoplay</td>
130+
<td>autoplay the video</td>
131+
<td>true</td>
132+
<td>boolean</td>
133+
</tr>
134+
<tr>
135+
<td>controls</td>
136+
<td>show player controls (youtube only)</td>
137+
<td>false</td>
138+
<td>boolean</td>
139+
</tr>
128140
<tr>
129141
<td>onFinished</td>
130142
<td>listen for the "finished" event</td>

src/okvideo.js

+24-16
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,32 @@ var player, OKEvents, options;
2828
// support older versions of okvideo
2929
if (base.options.video === null) base.options.video = base.options.source;
3030

31+
base.setOptions();
32+
3133
var target = base.options.target || $('body');
3234
var position = target[0] == $('body')[0] ? 'fixed' : 'absolute';
3335

3436
target.css({position: 'relative'});
3537

38+
var zIndex = base.options.controls === 3 ? -999 : "auto";
39+
var mask = '<div id="okplayer-mask" style="position:' + position + ';left:0;top:0;overflow:hidden;z-index:-998;height:100%;width:100%;"></div>';
40+
3641
if (OKEvents.utils.isMobile()) {
37-
target.append('<div id="okplayer" style="position:' + position + ';left:0;top:0;overflow:hidden;z-index:-999;height:100%;width:100%;"></div>');
42+
target.append('<div id="okplayer" style="position:' + position + ';left:0;top:0;overflow:hidden;z-index:' + zIndex + ';height:100%;width:100%;"></div>');
3843
} else if (base.options.adproof) {
39-
target.append('<div style="position:' + position + ';left:0;top:0;overflow:hidden;z-index:-998;height:100%;width:100%;" id="okplayer-mask"></div><div id="okplayer" style="position:' + position + ';left:0;top:0;overflow:hidden;z-index:-999;height:110%;width:110%;"></div>');
44+
if (base.options.controls === 3) {
45+
target.append(mask)
46+
}
47+
target.append('<div id="okplayer" style="position:' + position + ';left:-10%;top:-10%;overflow:hidden;z-index:' + zIndex + ';height:120%;width:120%;"></div>');
4048
} else {
41-
target.append('<div style="position:' + position + ';left:0;top:0;overflow:hidden;z-index:-998;height:100%;width:100%;" id="okplayer-mask"></div><div id="okplayer" style="position:' + position + ';left:0;top:0;overflow:hidden;z-index:-999;height:100%;width:100%;"></div>');
49+
if (base.options.controls === 3) {
50+
target.append(mask)
51+
}
52+
target.append('<div id="okplayer" style="position:' + position + ';left:0;top:0;overflow:hidden;z-index:' + zIndex + ';height:100%;width:100%;"></div>');
4253
}
4354

4455
$("#okplayer-mask").css("background-image", "url(" + BLANK_GIF + ")");
4556

46-
base.setOptions();
47-
4857

4958
if (base.options.playlist.list === null) {
5059
if (base.options.video.provider === 'youtube') {
@@ -66,10 +75,6 @@ var player, OKEvents, options;
6675
if (this.options[key] === false) this.options[key] = 3;
6776
}
6877

69-
if (base.options.autoplay === 3) {
70-
base.options.autoplay = 0;
71-
}
72-
7378
if (base.options.playlist.list === null) {
7479
base.options.video = base.determineProvider();
7580
}
@@ -90,7 +95,7 @@ var player, OKEvents, options;
9095
// load the vimeo api by replacing the div with an iframe and loading js
9196
base.loadVimeoAPI = function() {
9297
$('#okplayer').replaceWith(function() {
93-
return '<iframe src="http://player.vimeo.com/video/' + base.options.video.id + '?api=1&js_api=1&title=0&byline=0&portrait=0&playbar=0&loop=' + base.options.loop + '&autoplay=' + base.options.autoplay + '&player_id=okplayer" frameborder="0" style="' + $(this).attr('style') + 'visibility:hidden;background-color:black;" id="' + $(this).attr('id') + '"></iframe>';
98+
return '<iframe src="http://player.vimeo.com/video/' + base.options.video.id + '?api=1&js_api=1&title=0&byline=0&portrait=0&playbar=0&loop=' + base.options.loop + '&autoplay=' + (base.options.autoplay === 1 ? 1 : 0) + '&player_id=okplayer" frameborder="0" style="' + $(this).attr('style') + 'visibility:hidden;background-color:black;" id="' + $(this).attr('id') + '"></iframe>';
9499
});
95100

96101
base.insertJS('http://a.vimeocdn.com/js/froogaloop2.min.js', function(){
@@ -172,6 +177,7 @@ var player, OKEvents, options;
172177
onPlay: null,
173178
onPause: null,
174179
buffering: null,
180+
controls: false,
175181
autoplay: true,
176182
annotations: true,
177183
cued: null
@@ -219,10 +225,10 @@ function onYouTubePlayerAPIReady() {
219225
videoId: options.video ? options.video.id : null,
220226
playerVars: {
221227
'autohide': 1,
222-
'autoplay': options.autoplay,
228+
'autoplay': 0, //options.autoplay,
223229
'disablekb': options.keyControls,
224230
'cc_load_policy': options.captions,
225-
'controls': 0,
231+
'controls': options.controls,
226232
'enablejsapi': 1,
227233
'fs': 0,
228234
'modestbranding': 1,
@@ -246,10 +252,12 @@ OKEvents = {
246252
yt: {
247253
ready: function(event){
248254
event.target.setVolume(options.volume);
249-
if (options.playlist.list) {
250-
player.loadPlaylist(options.playlist.list, options.playlist.index, options.playlist.startSeconds, options.playlist.suggestedQuality);
251-
} else {
252-
event.target.playVideo();
255+
if (options.autoplay === 1) {
256+
if (options.playlist.list) {
257+
player.loadPlaylist(options.playlist.list, options.playlist.index, options.playlist.startSeconds, options.playlist.suggestedQuality);
258+
} else {
259+
event.target.playVideo();
260+
}
253261
}
254262
OKEvents.utils.isFunction(options.onReady) && options.onReady();
255263
},

src/okvideo.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)