uploading works, but AV info is not automatically detected and video activation featu...
[living-lab-site.git] / js / jquery.ui.nsvideo.js
index ccb461d..2d87c07 100644 (file)
@@ -28,7 +28,7 @@ $.widget( "ui.nsvideo", {
        },
        
        _create: function() {
-               var widget = this;
+               widget = this;
                
                widget.element
                        .addClass( "ui-widget ui-widget-content ui-corner-all" );
@@ -97,8 +97,8 @@ $.widget( "ui.nsvideo", {
                                .appendTo(widget.$controls);
                        $formats = $('.ui-nsvideo-formats', $formats[0]);
                        $.each(widget.options.src, function(index, value) {
-                               id = widget.element.attr('id') + '-format-' + index;
-                               definition = value.res.substring(value.res.indexOf('x')+1)+'p';
+                               var id = widget.element.attr('id') + '-format-' + index;
+                               var definition = value.res.substring(value.res.indexOf('x')+1)+'p';
                                $('<input type="radio" id="' + id + '" name="format" />')
                                        .appendTo($formats)
                                        .attr('checked', (index == widget.options.srcIndex))
@@ -187,7 +187,7 @@ $.widget( "ui.nsvideo", {
        },
        
        video: function() {
-               widget = this;
+               var widget = this;
                
                // Select video source.
                // If src option is string, that's the source.
@@ -199,6 +199,21 @@ $.widget( "ui.nsvideo", {
                
                widget.$videoContainer.html('');
                
+               // Install buttons or not supported message if required
+               if (typeof $.fn.nsinstall == 'function')
+               {
+                       widget.$installContainer = $('<div class="container-install-in-widget"></div>')
+                               .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;
                
@@ -234,6 +249,10 @@ $.widget( "ui.nsvideo", {
                                                widget.html5.refreshVolume();
                                                widget.html5.refreshState();
                                                widget._setWidgetWidth();
+                                               
+                                               if (widget.$video[0].error != 3
+                                                               && widget.$video[0].error != 4)
+                                                       widget.$installContainer.hide();
                                        },
                                        seeked: function() {
                                                widget.html5.play();
@@ -269,7 +288,7 @@ $.widget( "ui.nsvideo", {
                                        },
                                        seeking: function() {
                                                widget.html5.refreshState();
-                                       },
+                                       }
                                });
                }
                // VLC
@@ -363,6 +382,8 @@ $.widget( "ui.nsvideo", {
        },
        
        _setWidgetWidth: function() {
+        var widget = this;
+        
                if (widget.$video.width() < 640)
                {
                        widget.element.css('width',
@@ -685,6 +706,8 @@ $.widget( "ui.nsvideo", {
                },
                
                refreshState: function() {
+            var widget = this;
+            
                        var err = "";
                        var normal = "";
                        var network = "";
@@ -817,6 +840,11 @@ $.widget( "ui.nsvideo", {
                },
                
                play: function() {
+                       if(typeof widget.$video[0].playlist.isPlaying == 'undefined')
+                               return widget;
+                       
+                       widget.$installContainer.hide();
+                       
                        if (! widget.$video[0].playlist.isPlaying)
                                widget.$video[0].playlist.play();
                        
@@ -833,6 +861,9 @@ $.widget( "ui.nsvideo", {
                },
                
                pause: function() {
+                       if (typeof widget.$video[0].playlist === 'undefined')
+                               return widget;
+                       
                        if (widget.$video[0].playlist.isPlaying)
                                widget.$video[0].playlist.togglePause();