more work on the youtube rewrite front. nih-youtube
authorhamidouk
Tue, 31 Jan 2012 17:22:10 +0100
branchnih-youtube
changeset 756 f971fb0f2a3e
parent 755 d60401f66984
child 757 43e261bcd4ce
more work on the youtube rewrite front.
src/js/init.js
src/js/players/player.youtube.js
--- a/src/js/init.js	Tue Jan 31 16:54:08 2012 +0100
+++ b/src/js/init.js	Tue Jan 31 17:22:10 2012 +0100
@@ -106,10 +106,9 @@
           opts.autostart = false;
           templ = "width: {{width}}px; height: {{height}}px;";
           var str = Mustache.to_html(templ, {width: opts.width, height: opts.height});    
-          // Popcorn.youtube wants us to specify the size of the player in the style attribute of its container div.
-          IriSP.jQuery("#" + containerDiv).attr("style", str);
           
-          pop = Popcorn.youtube("#" + containerDiv, opts.video, opts);
+          //pop = Popcorn.youtube("#" + containerDiv, opts.video, opts);
+          pop = new IriSP.PopcornReplacement.youtube(containerDiv, opts);
         break;
         
       case "allocine":
--- a/src/js/players/player.youtube.js	Tue Jan 31 16:54:08 2012 +0100
+++ b/src/js/players/player.youtube.js	Tue Jan 31 17:22:10 2012 +0100
@@ -19,17 +19,26 @@
     setMute: function(p) { return jwplayer(this.container).setMute(p); }
   }
 
+  onYoutubePlayerReady = IriSP.wrap(this, this.ready);
   
   options.events = this.callbacks;
   var params = { allowScriptAccess: "always" };
-  var atts = { id: "ytplayer" };
-  swfobject.embedSWF("http://www.youtube.com/v/QH2-TGUlwu4?enablejsapi=1&playerapiid=ytplayer&version=3",
-                     container, "425", "356", "8", null, null, params, atts);
+  var atts = { id: container };
+  swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&version=3",
+                     container, options.width, options.height, "8", null, null, params, atts);
 
+  
 };
 
 IriSP.PopcornReplacement.jwplayer.prototype = new IriSP.PopcornReplacement.player("", {});
 
+IriSP.PopcornReplacement.jwplayer.prototype.ready = function(playerId) {
+  console.log("called");
+  this.player = IriSP.jQuery("#" + playerId).get(0);
+  this.player.loadVideoByUrl("http://www.youtube.com/v/QH2-TGUlwu4?version=3");
+  this.player.playVideo();
+};
+
 IriSP.PopcornReplacement.jwplayer.prototype.stateHandler = function(state) {
 
 };
\ No newline at end of file