зеркало из https://github.com/mozilla/popcorn-js.git
[#1185] Youtube height and width fixes, by way of deleted code :)
This commit is contained in:
Родитель
95478cfa1b
Коммит
9a17fc8b97
|
@ -175,7 +175,7 @@ Popcorn.player( "youtube", {
|
|||
|
||||
var youtubeInit = function() {
|
||||
|
||||
var src, width, height, originalStyle, query, styleWidth, styleHeight;
|
||||
var src, originalStyle, query;
|
||||
|
||||
var timeUpdate = function() {
|
||||
|
||||
|
@ -229,21 +229,12 @@ Popcorn.player( "youtube", {
|
|||
// cache original display property so it can be reapplied
|
||||
originalStyle = media.style.display;
|
||||
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;
|
||||
|
||||
options.youtubeObject = new YT.Player( container.id, {
|
||||
height: height,
|
||||
width: width,
|
||||
height: "100%",
|
||||
width: "100%",
|
||||
wmode: "transparent",
|
||||
playerVars: { wmode: "transparent" },
|
||||
videoId: src,
|
||||
|
|
|
@ -440,37 +440,26 @@ asyncTest( "Popcorn YouTube Plugin Url Regex Test", function() {
|
|||
|
||||
asyncTest( "Player height and width", function() {
|
||||
|
||||
expect( 6 );
|
||||
expect( 2 );
|
||||
|
||||
var popcorn1 = Popcorn.youtube( "#video4", "http://www.youtube.com/watch?v=nfGV32RNkhw" ),
|
||||
popcorn2 = Popcorn.youtube( "#video5", "http://www.youtube.com/watch?v=nfGV32RNkhw" ),
|
||||
popcorn3 = Popcorn.youtube( "#customHeight", "http://www.youtube.com/watch?v=nfGV32RNkhw" ),
|
||||
readyStatePoll = function() {
|
||||
var popcorn = Popcorn.youtube( "#video4", "http://www.youtube.com/watch?v=nfGV32RNkhw" );
|
||||
var readyStatePoll = function() {
|
||||
|
||||
if ( popcorn1.media.readyState !== 4 || popcorn2.media.readyState !== 4 || popcorn3.media.readyState !== 4 ) {
|
||||
if ( popcorn.media.readyState !== 4 ) {
|
||||
|
||||
setTimeout( readyStatePoll, 10 );
|
||||
} else {
|
||||
setTimeout( readyStatePoll, 10 );
|
||||
} else {
|
||||
|
||||
equal( popcorn1.media.children[ 0 ].width, 640, "Youtube player default width is 560" );
|
||||
equal( popcorn1.media.children[ 0 ].height, 390, "Youtube player default height is 315" );
|
||||
equal( popcorn.media.children[ 0 ].width, "100%",
|
||||
"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" );
|
||||
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 );
|
||||
popcorn.volume( 0 );
|
||||
|
||||
readyStatePoll();
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче