[#1185] Youtube height and width fixes, by way of deleted code :)

This commit is contained in:
Scott Downe 2012-07-09 12:38:37 -04:00
Родитель 95478cfa1b
Коммит 9a17fc8b97
2 изменённых файлов: 18 добавлений и 38 удалений

Просмотреть файл

@ -175,7 +175,7 @@ Popcorn.player( "youtube", {
var youtubeInit = function() { var youtubeInit = function() {
var src, width, height, originalStyle, query, styleWidth, styleHeight; var src, originalStyle, query;
var timeUpdate = function() { var timeUpdate = function() {
@ -229,21 +229,12 @@ Popcorn.player( "youtube", {
// cache original display property so it can be reapplied // cache original display property so it can be reapplied
originalStyle = media.style.display; originalStyle = media.style.display;
media.style.display = "inline"; media.style.display = "inline";
// setting youtube player's height and width, min 640 x 390,
// anything smaller, and the player reports incorrect states.
styleHeight = parseFloat( media.style.height );
styleWidth = parseFloat( media.style.width );
height = styleHeight > media.clientHeight ? styleHeight : media.clientHeight;
width = styleWidth > media.clientWidth ? styleWidth : media.clientWidth;
height = height >= 390 ? height : "390";
width = width >= 640 ? width: "640";
media.style.display = originalStyle; media.style.display = originalStyle;
options.youtubeObject = new YT.Player( container.id, { options.youtubeObject = new YT.Player( container.id, {
height: height, height: "100%",
width: width, width: "100%",
wmode: "transparent", wmode: "transparent",
playerVars: { wmode: "transparent" }, playerVars: { wmode: "transparent" },
videoId: src, videoId: src,

Просмотреть файл

@ -440,37 +440,26 @@ asyncTest( "Popcorn YouTube Plugin Url Regex Test", function() {
asyncTest( "Player height and width", function() { asyncTest( "Player height and width", function() {
expect( 6 ); expect( 2 );
var popcorn1 = Popcorn.youtube( "#video4", "http://www.youtube.com/watch?v=nfGV32RNkhw" ), var popcorn = Popcorn.youtube( "#video4", "http://www.youtube.com/watch?v=nfGV32RNkhw" );
popcorn2 = Popcorn.youtube( "#video5", "http://www.youtube.com/watch?v=nfGV32RNkhw" ), var readyStatePoll = function() {
popcorn3 = Popcorn.youtube( "#customHeight", "http://www.youtube.com/watch?v=nfGV32RNkhw" ),
readyStatePoll = function() {
if ( popcorn1.media.readyState !== 4 || popcorn2.media.readyState !== 4 || popcorn3.media.readyState !== 4 ) { if ( popcorn.media.readyState !== 4 ) {
setTimeout( readyStatePoll, 10 ); setTimeout( readyStatePoll, 10 );
} else { } else {
equal( popcorn1.media.children[ 0 ].width, 640, "Youtube player default width is 560" ); equal( popcorn.media.children[ 0 ].width, "100%",
equal( popcorn1.media.children[ 0 ].height, 390, "Youtube player default height is 315" ); "Youtube player default width is 560" );
equal( popcorn.media.children[ 0 ].height, "100%",
"Youtube player default height is 315" );
popcorn.destroy();
start();
}
};
equal( popcorn2.media.children[ 0 ].getAttribute( "width" ), 640, "Youtube player min width is 640" ); popcorn.volume( 0 );
equal( popcorn2.media.children[ 0 ].getAttribute( "height" ), 390, "Youtube player min height is 390" );
equal( popcorn3.media.children[ 0 ].width, 800, "Youtube correctly gets width style of container (800)" );
equal( popcorn3.media.children[ 0 ].height, 450, "Youtube correctly gets height style of container (450)" );
popcorn1.destroy();
popcorn2.destroy();
popcorn3.destroy();
start();
}
};
popcorn1.volume( 0 );
popcorn2.volume( 0 );
popcorn3.volume( 0 );
readyStatePoll(); readyStatePoll();
}); });