Skip to content

Commit

Permalink
Updating default settings. Appending controls to null setting.
Browse files Browse the repository at this point in the history
  • Loading branch information
georgepaterson committed May 9, 2011
1 parent b743f6f commit 9b7d2eb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 49 deletions.
9 changes: 3 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<script src="script/jquery.videobackground.js"></script>
<script>
$(document).ready(function() {
$('#video-background').videobackground({webm: 'video/dizzy.webm', ogv: 'video/dizzy.ogv', mp4: 'video/dizzy.m4v'});
$('#video-background').videobackground({webm: 'video/dizzy.webm', ogv: 'video/dizzy.ogv', mp4: 'video/dizzy.m4v', controls: '#main'});
});
</script>
</head>
Expand All @@ -73,12 +73,9 @@ <h1>jQuery Video Background plugin</h1>
<li>preload:</li>
<li>loop:</li>
<li>controls:</li>
<li>play:</li>
<li>pause:</li>
<li>mute:</li>
<li>unmute:</li>
<li>controlsText:</li>
<li>preloader:</li>
<li>preloadText:</li>
<li>preloadHtml:</li>
<li>loadedCallback:</li>
</ul>
<p>Videos from <a href="http://html5demos.com/">http://html5demos.com/</a>.</p>
Expand Down
76 changes: 33 additions & 43 deletions script/jquery.videobackground.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*!
* jQuery Video Background plugin
* https://github.com/georgepaterson/jquery-videobackground
*
* Copyright 2011, George Paterson
* Dual licensed under the MIT or GPL Version 2 licenses.
Expand Down Expand Up @@ -46,14 +47,11 @@
poster: null,
autoplay: true,
preload: 'none',
loop: false,
controls: '#main',
play: 'Play',
pause: 'Pause',
mute: 'Mute',
unmute: 'Unmute',
loop: true,
controls: null,
controlsText: ['Play', 'Pause', 'Mute', 'Unmute'],
preloader: true,
preloadText: '<p>Loading video</p><ul><li><a href="#">Skip video</a></li></ul>',
preloadHtml: '<p>Loading video</p><ul><li><a href="#">Skip video</a></li></ul>',
loadedCallback: null
};
$.fn.videobackground.methods = {
Expand All @@ -69,50 +67,48 @@
*/
var documentHeight = $(document).height();
$(self).css('height', documentHeight);
console.log($(document).height()+' '+ $(window).height())

/*
*
*
*/
controlbox = $('<div id="video-background-controls"></div>');
if (settings.controls) {
$(settings.controls).append(controlbox);
}
else {
$(self).append(controlbox);
}
/*
*
*
*/
var source = '';
if (settings.webm) {
source = source + '<source src="'+settings.webm+'">'
source = source + '<source src="'+settings.webm+'">';
}
if (settings.ogv) {
source = source + '<source src="'+settings.ogv+'">'
source = source + '<source src="'+settings.ogv+'">';
}
if (settings.mp4) {
source = source + '<source src="'+settings.mp4+'">'
source = source + '<source src="'+settings.mp4+'">';
}
var attributes = '';
attributes = attributes + 'preload="'+settings.preload+'"'
attributes = attributes + 'preload="'+settings.preload+'"';
if (settings.poster) {
attributes = attributes + ' poster="'+settings.poster+'"'
attributes = attributes + ' poster="'+settings.poster+'"';
}
if (settings.autoplay) {
attributes = attributes + ' autoplay="autoplay"'
attributes = attributes + ' autoplay="autoplay"';
}
if (settings.loop) {
attributes = attributes + ' loop="loop"'
attributes = attributes + ' loop="loop"';
}
$(self).html('<video '+attributes+'>'+source+'</video>');
/*
*
*
*/
controls = $('<ul class="controls"><li><a class="play" href="#">'+settings.pause+'</a></li><li><a class="mute" href="#">'+settings.mute+'</a></li></ul>');
controlbox = $('<div id="video-background-controls"></div>');
if (settings.controls) {
$(settings.controls).append(controlbox);
}
else {
$(self).append(controlbox);
}
/*
*
*
*/
controls = $('<ul class="controls"><li><a class="play" href="#">'+settings.controlsText[1]+'</a></li><li><a class="mute" href="#">'+settings.controlsText[2]+'</a></li></ul>');
/*
*
*
Expand All @@ -132,21 +128,15 @@
*
*/
preload: function() {
preloading = $(settings.preloadText);
$(controlbox).append(preloading);
$(controlbox).append(settings.preloadHTML);
},
/*
*
*
*/
loaded: function() {
if (settings.controls) {
$(controlbox).html(controls);
}
else {
$(controlbox).html(controls);
}
$.fn.videobackground.methods.events();
$(controlbox).html(controls);
$.fn.videobackground.methods.loadedEvents();
if(settings.loadedCallback) {
(settings.loadedCallback).call(this);
}
Expand All @@ -155,7 +145,7 @@
* Video events.
*
*/
events: function() {
loadedEvents: function() {
/*
*
*
Expand All @@ -176,18 +166,18 @@
if ($('video', self).get(0).paused) {
$('video', self).get(0).play();
$(this).toggleClass('paused');
$(this).text(settings.pause);
$(this).text(settings.controlsText[1]);
}
else {
if ($('video', self).get(0).ended) {
$('video', self).get(0).play();
$(this).toggleClass('paused');
$(this).text(settings.pause);
$(this).text(settings.controlsText[1]);
}
else {
$('video', self).get(0).pause();
$(this).toggleClass('paused');
$(this).text(settings.play);
$(this).text(settings.controlsText[0]);
}
}
});
Expand All @@ -201,13 +191,13 @@
$('video', self).attr('muted', false);
$('video', self).get(0).volume = 1;
$(this).toggleClass('muted');
$(this).text(settings.mute);
$(this).text(settings.controlsText[2]);
}
else {
$('video', self).attr('muted', true);
$('video', self).get(0).volume = 0;
$(this).toggleClass('muted');
$(this).text(settings.unmute);
$(this).text(settings.controlsText[3]);
}
});
},
Expand Down

0 comments on commit 9b7d2eb

Please sign in to comment.