]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
[#422] Done. can be specified in ctor or styles
authorstevenaw <sweerdenburg@gmail.com>
Thu, 21 Apr 2011 00:21:29 +0000 (20:21 -0400)
committerstevenaw <sweerdenburg@gmail.com>
Thu, 21 Apr 2011 00:21:29 +0000 (20:21 -0400)
players/vimeo/popcorn.vimeo.html
players/vimeo/popcorn.vimeo.js
players/vimeo/popcorn.vimeo.unit.html
players/youtube/popcorn.youtube.html
players/youtube/popcorn.youtube.js
players/youtube/popcorn.youtube.unit.html

index fcad8dafc728199d78ca299531d9c406a00ec6d3..a55c36fff54dbf23ad043333b51eeaa6faf6b356 100644 (file)
 
             //On document ready
             document.addEventListener( "DOMContentLoaded", function() {
-              var player = Popcorn( Popcorn.vimeo( "player_1" ) )
+              var player = Popcorn( Popcorn.vimeo( "player_1", "http://player.vimeo.com/video/11127501", {
+                  width: 500,
+                  height: 281
+                }) )
                     .footnote({
                       start: 5, // seconds
                       end: 40, // seconds
     </head>
     <body>
           <div>
-            <div id="player_1" width="500" height="281" src="http://player.vimeo.com/video/11127501" ></div><br />
+            <div id="player_1" ></div><br />
             <button class="simple" id="btnPlay">Play</button>
             <button class="simple" id="btnPause">Pause</button>
             <button class="seek" id="btnSeek">Seek to 30</button>
index 9c73f5117eac5691023310e7cf49644c026ebd90..3f5be0495c2d358ddffec91af69343b6b071e5c5 100644 (file)
       
       // Try and get a video id from a vimeo site url
       // Try either from ctor param or from iframe itself
-      if( videoUrl ) {
-        vidId = extractIdFromUrl( videoUrl ) || extractIdFromUri( videoUrl );
-      } 
-
-      if ( !vidId ){
-        vidId = extractIdFromUrl( this._container.getAttribute("src") ) || extractIdFromUri( this._container.getAttribute("src") );
-      }
+      vidId = extractIdFromUrl( videoUrl ) || extractIdFromUri( videoUrl );
       
       if ( !vidId ) {
         throw "No video id";
index 6b4bddb120002c6c79d76b9bce76eb0ad0bbdce7..91c9d37f1148b64492898e98c476083daa76c0a3 100644 (file)
@@ -23,6 +23,6 @@
   <ol id="qunit-tests"></ol>
   <div id="qunit-fixture">  </div>
   
-  <div id="player_1" width="500" height="281"></div>
+  <div id="player_1"></div>
 </body>
 </html>
index c61f97db5e5a7f213bda65254a800a04fec320ad..b340c165939ad33505a6d11516d1dd29e2fa22b5 100644 (file)
@@ -22,7 +22,7 @@
           var paused = true,
               popcorn;
           
-          popcorn = Popcorn( Popcorn.youtube( 'video', 'http://www.youtube.com/watch?v=9oar9glUCL0' ) );
+          popcorn = Popcorn( Popcorn.youtube( 'video', 'http://www.youtube.com/watch?v=9oar9glUCL0', { width: 400 } ) );
           
           popcorn = popcorn
             .footnote({
index 0c093e1394b6831e4a17c2b5acd1a3ae9e401399..8b236189c90327cea403125f6cdea0a7d06e5b84 100644 (file)
@@ -96,14 +96,6 @@ var onYouTubePlayerReady;
         makeSWF.call( self, url, container );
       }, 1 );
       return;
-    }    
-        
-    // The video id for youtube (web or player formats)
-    // First check manually given url, if that doesn't work resort to "src"
-    this.vidId = this.vidId || extractIdFromUrl( container.getAttribute( "src" ) ) || extractIdFromUri( container.getAttribute( "src" ) );
-    
-    if ( !this.vidId ) {
-      throw "Could not find video id";
     }
     
     bounds = container.getBoundingClientRect();
@@ -158,17 +150,19 @@ var onYouTubePlayerReady;
     vid.dispatchEvent( "durationchange" );
   }
 
-  Popcorn.youtube = function( elementId, url ) {
-    return new Popcorn.youtube.init( elementId, url );
+  Popcorn.youtube = function( elementId, url, options ) {
+    return new Popcorn.youtube.init( elementId, url, options );
   };
 
-  Popcorn.youtube.init = function( elementId, url ) {
+  Popcorn.youtube.init = function( elementId, url, options ) {
     if ( !elementId ) {
       throw "Element id is invalid.";
     } else if ( /file/.test( location.protocol ) ) {
       throw "This must be run from a web server.";
     }
     
+    options = options || {};
+    
     var self = this;
     
     this.playerId = elementId + Popcorn.guid();
@@ -178,11 +172,14 @@ var onYouTubePlayerReady;
     this.loadedData = false;
     this.fullyLoaded = false;
     
+    options.width = options.width && (+options.width)+"px";
+    options.height = options.height && (+options.height)+"px";
+    
     this._target = document.getElementById( elementId );
     this._container = document.createElement( "div" );
     this._container.id = this.playerId;
-    this._container.style.height = this._target.style.height = this._target.style.height || "350px";
-    this._container.style.width  = this._target.style.width  = this._target.style.width  || "460px";
+    this._container.style.height = this._target.style.height = options.height || this._target.style.height || "350px";
+    this._container.style.width  = this._target.style.width  = options.width || this._target.style.width  || "460px";
     this._target.appendChild( this._container );
 
     this.offsetHeight = +this._target.offsetHeight;
@@ -194,6 +191,10 @@ var onYouTubePlayerReady;
     
     this.vidId = extractIdFromUrl( url ) || extractIdFromUri( url );
     
+    if ( !this.vidId ) {
+      throw "Could not find video id";
+    }
+    
     this.addEventListener( "load", function() {
       // For calculating position relative to video (like subtitles)
       this.offsetWidth = this.video.offsetWidth;
index 54c3f84c48869880ec2ee4724c8a000d7c57207b..ce0a83c299823937ea5d7566b1ebb56b5f81e722 100644 (file)
@@ -28,8 +28,8 @@
     Therefore, if failures occur for the first time, just run it again. Likely,
     failures would disappear the second time.
   </p>
-  <div id="video" width="360" height="300"></div>
-  <div id="video2" width="360" height="300"></div>
+  <div id="video" style="width: 360px; height: 300px" ></div>
+  <div id="video2" style="width: 360px; height: 300px" ></div>
 </body>
 </html>