Commit c667c013 by Valera Rozuvan

Fix start-time functionality in the video player.

When there is a start-time:

Initially, the video starts playing from the start-time.
Whenever the player resets for any reason (such as reaching
the end of the video), it will reset to start-time instead of 00:00:00.
It should not be the case that any time the user presses play, it
start playing from start-time.

BLD-659.
parent 663671ec
......@@ -221,7 +221,7 @@
expect(state.videoPlayer.play).toHaveBeenCalled();
});
it('when cued, onEnded resets start and end time only the second time', function () {
it('even when cued, onEnded does not resets start and end time', function () {
state.videoPlayer.skipOnEndedStartEndReset = true;
state.videoPlayer.onEnded();
expect(state.videoPlayer.startTime).toBe(10);
......@@ -229,8 +229,8 @@
state.videoPlayer.skipOnEndedStartEndReset = undefined;
state.videoPlayer.onEnded();
expect(state.videoPlayer.startTime).toBe(0);
expect(state.videoPlayer.endTime).toBe(null);
expect(state.videoPlayer.startTime).toBe(10);
expect(state.videoPlayer.endTime).toBe(30);
});
});
......
......@@ -562,6 +562,7 @@ function (VideoPlayer) {
runs(function () {
var htmlStr;
state.videoPlayer.goToStartTime = false;
state.videoPlayer.updatePlayTime(60);
htmlStr = $('.vidtime').html();
......@@ -589,6 +590,7 @@ function (VideoPlayer) {
}, 'Video is fully loaded.', WAIT_TIMEOUT);
runs(function () {
state.videoPlayer.goToStartTime = false;
state.videoPlayer.updatePlayTime(60);
expect(state.videoCaption.updatePlayTime)
......@@ -606,6 +608,7 @@ function (VideoPlayer) {
}, 'Video is fully loaded.', WAIT_TIMEOUT);
runs(function () {
state.videoPlayer.goToStartTime = false;
state.videoPlayer.updatePlayTime(60);
expect(state.videoProgressSlider.updatePlayTime)
......@@ -677,35 +680,39 @@ function (VideoPlayer) {
describe('updatePlayTime with invalid endTime', function () {
beforeEach(function () {
state = jasmine.initializePlayer(
{
end: 100000
}
);
state.videoEl = $('video, iframe');
spyOn(state.videoPlayer, 'updatePlayTime').andCallThrough();
state = {
videoPlayer: {
duration: function () {
// The video will be 60 seconds long.
return 60;
},
goToStartTime: true,
startTime: undefined,
endTime: undefined,
player: {
seekTo: function () {}
}
},
config: {
savedVideoPosition: 0,
startTime: 0,
// We are setting the end-time to 10000 seconds. The
// video will be less than this, the code will reset
// the end time to `null` - i.e. to the end of the video.
// This is the expected behavior we will test for.
endTime: 10000
},
currentPlayerMode: 'html5',
trigger: function () {},
browserIsFirefox: false
};
});
it('invalid endTime is reset to null', function () {
var duration;
VideoPlayer.prototype.updatePlayTime.call(state, 0);
state.videoPlayer.updatePlayTime.reset();
state.videoPlayer.play();
waitsFor(
function () {
return state.videoPlayer.isPlaying() &&
state.videoPlayer.initialSeekToStartTime === false;
},
'updatePlayTime was invoked and duration is set',
WAIT_TIMEOUT
);
runs(function () {
expect(state.videoPlayer.endTime).toBe(null);
});
expect(state.videoPlayer.endTime).toBe(null);
});
});
......
......@@ -180,6 +180,10 @@ function () {
function onSlide(event, ui) {
this.videoProgressSlider.frozen = true;
// Remember the seek to value so that we don't repeat ourselves on the
// 'stop' slider event.
this.videoProgressSlider.lastSeekValue = ui.value;
this.trigger(
'videoPlayer.onSlideSeek',
{'type': 'onSlideSeek', 'time': ui.value}
......@@ -196,10 +200,16 @@ function () {
this.videoProgressSlider.frozen = true;
this.trigger(
'videoPlayer.onSlideSeek',
{'type': 'onSlideSeek', 'time': ui.value}
);
// Only perform a seek if we haven't made a seek for the new slider value.
// This is necessary so that if the user only clicks on the slider, without
// dragging it, then only one seek is made, even when a 'slide' and a 'stop'
// events are triggered on the slider.
if (this.videoProgressSlider.lastSeekValue !== ui.value) {
this.trigger(
'videoPlayer.onSlideSeek',
{'type': 'onSlideSeek', 'time': ui.value}
);
}
// ARIA
this.videoProgressSlider.handle.attr(
......@@ -216,8 +226,8 @@ function () {
duration = Math.floor(params.duration);
if (
(this.videoProgressSlider.slider) &&
(!this.videoProgressSlider.frozen)
this.videoProgressSlider.slider &&
!this.videoProgressSlider.frozen
) {
this.videoProgressSlider.slider
.slider('option', 'max', duration)
......
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