X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=blobdiff_plain;f=js%2Fjquery.ui.nsvideo.js;h=e556fda937e233750913e1ab0040e37ba7343d41;hb=ac366a43f0cda63c2506321104b6760c153ac993;hp=0dd901422e8f93823f6663aaf5d3d53e4fd2db73;hpb=edac3c0e2d7251d0223cd8809f12fbfcb1eac8d1;p=living-lab-site.git diff --git a/js/jquery.ui.nsvideo.js b/js/jquery.ui.nsvideo.js index 0dd9014..e556fda 100644 --- a/js/jquery.ui.nsvideo.js +++ b/js/jquery.ui.nsvideo.js @@ -1,5 +1,5 @@ /* - * jQuery UI NS-Video @VERSION + * jQuery UI NS-Video 1.0.0 beta * * Copyright 2011, Călin-Andrei Burloiu * Dual licensed under the MIT or GPL Version 2 licenses. @@ -13,18 +13,20 @@ (function( $, undefined ) { $.widget( "ui.nsvideo", { - version: "@VERSION", + version: "1.0.0 beta", options: { type: 'ns-html5', - width: 800, - height: 450, - showStatus: true, + srcIndex: 0, + width: 0, + height: 0, + minWidth: 0, + maxWidth: 0, + showState: true, refreshInterval: 0.1, // seconds - autoplay: false + autoplay: false, + initialDuration: "--:--" }, - - min: 0, - + _create: function() { var widget = this; @@ -54,9 +56,11 @@ $.widget( "ui.nsvideo", { .slider({ value: 0, min: 0, - max: 1000, //Math.floor(widget.$video[0].duration), + max: 1000, slide: function(event, ui) { widget.videoPlugin('crtTime', [ui.value]); + widget.videoPlugin('refreshTime'); + widget.videoPlugin('refreshState'); } }); @@ -72,7 +76,7 @@ $.widget( "ui.nsvideo", { }); // Time information (current and total) - widget.$time = $('
--:-- / --:--
') + widget.$time = $('
00:00 / ' + widget.options.initialDuration + '
') .appendTo(widget.$controls); // Full screen @@ -86,26 +90,27 @@ $.widget( "ui.nsvideo", { widget.videoPlugin('fullscreen'); }); - // Video definition buttonset + // Video format buttonset if (typeof widget.options.src == 'object') { - var $definitions = $('
') + var $formats = $('
') .appendTo(widget.$controls); - $definitions = $('.ui-nsvideo-definitions', $definitions[0]); + $formats = $('.ui-nsvideo-formats', $formats[0]); $.each(widget.options.src, function(index, value) { - id = widget.element.attr('id') + '-def-' + index; - $('') - .appendTo($definitions) - .attr('checked', (index == widget.options.definition)) + id = widget.element.attr('id') + '-format-' + index; + definition = value.res.substring(value.res.indexOf('x')+1)+'p'; + $('') + .appendTo($formats) + .attr('checked', (index == widget.options.srcIndex)) .click(function() { widget.videoPlugin('pause'); - widget.definition(index); + widget.srcIndex(index); }); - $('') - .appendTo($definitions); + $('') + .appendTo($formats); }); - $definitions.buttonset(); + $formats.buttonset(); } // Volume @@ -132,24 +137,18 @@ $.widget( "ui.nsvideo", { }); // Status information - if (widget.options.showStatus) - { - widget.$stateText = $('
...
') - .appendTo(widget.$controls) - .css('cursor', 'pointer') - .click(function() { - widget.videoPlugin('refreshAll'); - }); - } + widget.$stateText = $('
...
') + .appendTo(widget.$controls) + .css('cursor', 'pointer') + .click(function() { + widget.videoPlugin('refreshAll'); + }); + if (! widget.options.showState) + widget.$stateText.hide(); // Clear fix helper $('
') .appendTo(widget.$controls); - - // Initialize video plugin - widget.$video.ready(function() { - widget.videoPlugin('init'); - }); }, _destroy: function() { @@ -192,31 +191,52 @@ $.widget( "ui.nsvideo", { // Select video source. // If src option is string, that's the source. - // If src is an object, properties are definitions and values are - // sources. + // If src is an object, there is a list of associative arrays, each + // one having the mandatory keys "src" and "res" (resolution). var src = widget.crtSrc(); if (src == null) return widget; widget.$videoContainer.html(''); + // Install buttons or not supported message if required + if (typeof $.fn.nsinstall == 'function') + { + widget.$installContainer = $('
') + .appendTo(widget.$videoContainer); + widget.$installContainer + .nsinstall({ + type: widget.options.type, + hideIfAlreadyInstalled: true + }); + if (widget.$installContainer.nsinstall('option', 'error') + == 'already installed') + widget.$installContainer.hide(); + } + + var width = widget.options.width; + var height = widget.options.height; + // HTML5 if (widget.options.type == 'ns-html5' || widget.options.type == 'html5') { - widget.$video = $('