From: ScottDowne Date: Wed, 20 Apr 2011 23:18:34 +0000 (-0400) Subject: [#475] youtube now working for position and offsetWidth/Height, subtitles now fixed X-Git-Tag: v0.5~10^2~1 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=cebaa3aba42c75cca83d239e5d2372b8e7b1067c;p=popcorn-js.git [#475] youtube now working for position and offsetWidth/Height, subtitles now fixed --- diff --git a/players/youtube/popcorn.youtube.html b/players/youtube/popcorn.youtube.html index 004428a..c61f97d 100644 --- a/players/youtube/popcorn.youtube.html +++ b/players/youtube/popcorn.youtube.html @@ -140,7 +140,7 @@
-

+

diff --git a/players/youtube/popcorn.youtube.js b/players/youtube/popcorn.youtube.js index a64efa6..0c093e1 100644 --- a/players/youtube/popcorn.youtube.js +++ b/players/youtube/popcorn.youtube.js @@ -109,8 +109,8 @@ var onYouTubePlayerReady; bounds = container.getBoundingClientRect(); // Determine width/height/etc based on container - this.width = container.getAttribute("width") || 460; - this.height = container.getAttribute("height") || 350; + this.width = container.style.width || 460; + this.height = container.style.height || 350; // Just in case we got the attributes as strings. We'll need to do math with these later this.width = parseFloat(this.width); @@ -171,14 +171,22 @@ var onYouTubePlayerReady; var self = this; - this.playerId = elementId; + this.playerId = elementId + Popcorn.guid(); this.readyState = READY_STATE_HAVE_NOTHING; this._eventListeners = {}; this.loadStarted = false; this.loadedData = false; this.fullyLoaded = false; - this._container = document.getElementById( elementId ); + 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._target.appendChild( this._container ); + + this.offsetHeight = +this._target.offsetHeight; + this.offsetWidth = +this._target.offsetWidth; this.currentTime = this.previousCurrentTime = 0; this.volume = this.previousVolume = this.preMuteVol = 1; @@ -333,7 +341,7 @@ var onYouTubePlayerReady; if ( !loadedPlayers[this.playerId] ) { this.addEventListener( "load", function() { this.load(); -} ); + }); return; } @@ -434,16 +442,16 @@ var onYouTubePlayerReady; height: b.height || ( b.bottom - b.top ) }; } else { - b = this._container.getBoundingClientRect(); + b = self._container.getBoundingClientRect(); // Update bottom, right for expected values once the container loads return { left: b.left, top: b.top, - width: self.offsetWidth, - height: self.offsetHeight, - bottom: b.top + this.width, - right: b.top + this.height + width: self._target.offsetWidth, + height: self._target.offsetHeight, + bottom: b.top + self._target.offsetWidth, + right: b.left + self._target.offsetHeight }; } }, diff --git a/popcorn.js b/popcorn.js index e03ecaf..8adf382 100644 --- a/popcorn.js +++ b/popcorn.js @@ -420,7 +420,6 @@ for ( var p in clientRect ) { bounds[ p ] = Math.round( clientRect[ p ] ); } - return Popcorn.extend({}, bounds, { top: top, left: left }); } });