Commit 76de7f60 by jmclaus

Merge pull request #2855 from edx/anton/fix-fullscreen-in-flash

Fix video resizing in Flash mode.
parents 8d15acc9 07ed3685
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<span tabindex="-1" class="btn-play is-hidden" aria-hidden="true" aria-label="${_('Play video')}"></span> <span tabindex="-1" class="btn-play is-hidden" aria-hidden="true" aria-label="${_('Play video')}"></span>
<div class="video-player-pre"></div> <div class="video-player-pre"></div>
<section class="video-player"> <section class="video-player">
<div id="id"></div> <iframe id="id"></iframe>
</section> </section>
<div class="video-player-post"></div> <div class="video-player-post"></div>
<section class="video-controls is-hidden"> <section class="video-controls is-hidden">
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<span tabindex="0" class="spinner" aria-hidden="false" aria-label="${_('Loading video player')}"></span> <span tabindex="0" class="spinner" aria-hidden="false" aria-label="${_('Loading video player')}"></span>
<span tabindex="-1" class="btn-play is-hidden" aria-hidden="true" aria-label="${_('Play video')}"></span> <span tabindex="-1" class="btn-play is-hidden" aria-hidden="true" aria-label="${_('Play video')}"></span>
<section class="video-player"> <section class="video-player">
<div id="id"></div> <iframe id="id"></iframe>
</section> </section>
<section class="video-controls is-hidden"></section> <section class="video-controls is-hidden"></section>
</article> </article>
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<span tabindex="-1" class="btn-play is-hidden" aria-hidden="true" aria-label="${_('Play video')}"></span> <span tabindex="-1" class="btn-play is-hidden" aria-hidden="true" aria-label="${_('Play video')}"></span>
<div class="video-player-pre"></div> <div class="video-player-pre"></div>
<section class="video-player"> <section class="video-player">
<div id="id1"></div> <iframe id="id1"></iframe>
</section> </section>
<div class="video-player-post"></div> <div class="video-player-post"></div>
<section class="video-controls is-hidden"> <section class="video-controls is-hidden">
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
<article class="video-wrapper"> <article class="video-wrapper">
<div class="video-player-pre"></div> <div class="video-player-pre"></div>
<section class="video-player"> <section class="video-player">
<div id="id2"></div> <iframe id="id2"></iframe>
</section> </section>
<div class="video-player-post"></div> <div class="video-player-post"></div>
<section class="video-controls"> <section class="video-controls">
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
<article class="video-wrapper"> <article class="video-wrapper">
<div class="video-player-pre"></div> <div class="video-player-pre"></div>
<section class="video-player"> <section class="video-player">
<div id="id3"></div> <iframe id="id3"></iframe>
</section> </section>
<div class="video-player-post"></div> <div class="video-player-post"></div>
<section class="video-controls"> <section class="video-controls">
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
'getPlayerState', 'getVolume', 'setVolume', 'getPlayerState', 'getVolume', 'setVolume',
'loadVideoById', 'getAvailablePlaybackRates', 'playVideo', 'loadVideoById', 'getAvailablePlaybackRates', 'playVideo',
'pauseVideo', 'seekTo', 'getDuration', 'setPlaybackRate', 'pauseVideo', 'seekTo', 'getDuration', 'setPlaybackRate',
'getPlaybackQuality' 'getPlaybackQuality', 'destroy'
] ]
); );
...@@ -238,7 +238,8 @@ ...@@ -238,7 +238,8 @@
'alignByWidthOnly', 'alignByWidthOnly',
'alignByHeightOnly', 'alignByHeightOnly',
'setParams', 'setParams',
'setMode' 'setMode',
'setElement'
], ],
obj = {}, obj = {},
delta = { delta = {
......
...@@ -51,8 +51,7 @@ function (Resizer) { ...@@ -51,8 +51,7 @@ function (Resizer) {
it('`alignByHeightOnly` works correctly', function () { it('`alignByHeightOnly` works correctly', function () {
var resizer = new Resizer(config).alignByHeightOnly(), var resizer = new Resizer(config).alignByHeightOnly(),
expectedHeight = container.height(), expectedHeight = container.height(),
realHeight = element.height(), realHeight = element.height();
realWidth;
expect(realHeight).toBe(expectedHeight); expect(realHeight).toBe(expectedHeight);
}); });
...@@ -92,6 +91,20 @@ function (Resizer) { ...@@ -92,6 +91,20 @@ function (Resizer) {
expect(realWidth).toBe(expectedWidth); expect(realWidth).toBe(expectedWidth);
}); });
it('`setElement` works correctly', function () {
container.append('<div ' +
'id="Another-el" ' +
'style="width:100px; height: 150px;"' +
'>');
var newElement = $('#Another-el'),
expectedHeight = container.height();
new Resizer(config).setElement(newElement).alignByHeightOnly();
expect(element.height()).not.toBe(expectedHeight);
expect(newElement.height()).toBe(expectedHeight);
});
describe('Callbacks', function () { describe('Callbacks', function () {
var resizer, var resizer,
spiesList = []; spiesList = [];
......
...@@ -316,8 +316,6 @@ ...@@ -316,8 +316,6 @@
}); });
waitsFor(function () { waitsFor(function () {
c1 += 1;
console.log('c1 = ', c1);
duration = state.videoPlayer.duration(); duration = state.videoPlayer.duration();
return isFinite(duration) && duration > 0 && return isFinite(duration) && duration > 0 &&
...@@ -325,21 +323,11 @@ ...@@ -325,21 +323,11 @@
}, 'duration is set', WAIT_TIMEOUT); }, 'duration is set', WAIT_TIMEOUT);
runs(function () { runs(function () {
console.log('oiooio');
console.log(state.videoProgressSlider.slider);
console.log('0000');
expect($('.video-controls').find('.vidtime')) expect($('.video-controls').find('.vidtime'))
.toHaveText('0:00 / 1:00'); .toHaveText('0:00 / 1:00');
console.log('1111');
expect(true).toBe(true); expect(true).toBe(true);
expect(state.videoProgressSlider.slider.slider('option', 'value')).toBe(0);
console.log('1111');
// expect(state.videoProgressSlider.slider.slider('option', 'value')).toBe(0);
state.storage.clear(); state.storage.clear();
}); });
}); });
...@@ -367,7 +355,6 @@ ...@@ -367,7 +355,6 @@
.toHaveText('0:00 / 1:00'); .toHaveText('0:00 / 1:00');
expect(state.videoProgressSlider.slider.slider('option', 'value')).toBe(0); expect(state.videoProgressSlider.slider.slider('option', 'value')).toBe(0);
state.storage.clear(); state.storage.clear();
}); });
}); });
...@@ -396,7 +383,6 @@ ...@@ -396,7 +383,6 @@
.toHaveText('0:00 / 1:00'); .toHaveText('0:00 / 1:00');
expect(state.videoProgressSlider.slider.slider('option', 'value')).toBe(0); expect(state.videoProgressSlider.slider.slider('option', 'value')).toBe(0);
state.storage.clear(); state.storage.clear();
}); });
}); });
...@@ -427,7 +413,6 @@ ...@@ -427,7 +413,6 @@
.toHaveText('0:10 / 1:00'); .toHaveText('0:10 / 1:00');
expect(state.videoProgressSlider.slider.slider('option', 'value')).toBe(10); expect(state.videoProgressSlider.slider.slider('option', 'value')).toBe(10);
state.storage.clear(); state.storage.clear();
}); });
}); });
......
...@@ -102,6 +102,34 @@ function (VideoPlayer) { ...@@ -102,6 +102,34 @@ function (VideoPlayer) {
}); });
}); });
it('create Flash player', function () {
var player;
state = jasmine.initializePlayerYouTube();
state.videoEl = state.el.find('video, iframe').width(100);
player = state.videoPlayer.player;
player.getAvailablePlaybackRates.andReturn([1]);
state.currentPlayerMode = 'html5';
spyOn(window.YT, 'Player').andCallThrough();
state.videoPlayer.onReady();
expect(YT.Player).toHaveBeenCalledWith('id', {
playerVars: {
controls: 0,
wmode: 'transparent',
rel: 0,
showinfo: 0,
enablejsapi: 1,
modestbranding: 1
},
videoId: 'abcdefghijkl',
events: jasmine.any(Object)
});
expect(state.resizer.setElement).toHaveBeenCalled();
expect(state.resizer.align).toHaveBeenCalled();
});
// We can't test the invocation of HTML5Video because it is not // We can't test the invocation of HTML5Video because it is not
// available globally. It is defined within the scope of Require // available globally. It is defined within the scope of Require
// JS. // JS.
......
...@@ -126,6 +126,12 @@ function () { ...@@ -126,6 +126,12 @@ function () {
return module; return module;
}; };
var setElement = function (element) {
config.element = element;
return module;
};
var addCallback = function (func) { var addCallback = function (func) {
if ($.isFunction(func)) { if ($.isFunction(func)) {
callbacksList.push(func); callbacksList.push(func);
...@@ -202,6 +208,7 @@ function () { ...@@ -202,6 +208,7 @@ function () {
alignByHeightOnly: alignByHeightOnly, alignByHeightOnly: alignByHeightOnly,
setParams: initialize, setParams: initialize,
setMode: setMode, setMode: setMode,
setElement: setElement,
callbacks: { callbacks: {
add: addCallback, add: addCallback,
once: addOnceCallback, once: addOnceCallback,
......
...@@ -270,6 +270,8 @@ function (HTML5Video, Resizer) { ...@@ -270,6 +270,8 @@ function (HTML5Video, Resizer) {
.onPlaybackQualityChange .onPlaybackQualityChange
} }
}); });
state.resizer.setElement(state.el.find('iframe')).align();
} }
// *************************************************************** // ***************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment