src/js/init.js
branchnew-model
changeset 883 d35ad8111c5e
parent 882 61c384dda19e
child 884 10233337f6da
--- a/src/js/init.js	Thu May 03 17:52:52 2012 +0200
+++ b/src/js/init.js	Fri May 04 16:56:41 2012 +0200
@@ -34,14 +34,7 @@
         $L.script(IriSP.getLib("jwplayer"));
     } else {
         // load the real popcorn
-        $L.script(IriSP.getLib("popcorn")).script(IriSP.getLib("popcorn.code"));
-        // load plugins if necessary
-        if(this.config.player.type === "youtube") {
-            $L.script(IriSP.getLib("popcorn.youtube"));
-        }
-        if(this.config.player.type === "vimeo"){
-            $L.script(IriSP.getLib("popcorn.vimeo"));
-        }
+        $L.script(IriSP.getLib("popcorn"));
     }
 
     /* widget specific requirements */
@@ -186,16 +179,21 @@
             break;
 
         case "youtube":
-            var opts = IriSP.jQuery.extend({}, this.config.player);
-            delete opts.container;
-            opts.controls = 0;
-            opts.autostart = false;
             // Popcorn.youtube wants us to specify the size of the player in the style attribute of its container div.
             IriSP.jQuery("#" + containerDiv).css({
-                width : opts.width + "px",
-                height : opts.height + "px"
-            })
-            pop = Popcorn.youtube("#" + containerDiv, opts.video, opts);
+                width : this.config.player.width + "px",
+                height : this.config.player.height + "px"
+            });
+            var _urlparts = this.config.player.video.split(/[?&]/),
+                _params = {};
+            for (var _j = 1; _j < _urlparts.length; _j++) {
+                var _ppart = _urlparts[_j].split('=');
+                _params[_ppart[0]] = decodeURIComponent(_ppart[1]);
+            }
+            _params.controls = 0;
+            _params.modestbranding = 1;
+            _url = _urlparts[0] + '?' + IriSP.jQuery.param(_params);
+            pop = Popcorn.youtube("#" + containerDiv, _url);
             break;
 
         case "dailymotion":