Commit 215816b5 by Valera Rozuvan

Start-end time range always shown, even before video plays.

BLD-529.
parent 33031b76
...@@ -60,7 +60,7 @@ function (HTML5Video, Resizer) { ...@@ -60,7 +60,7 @@ function (HTML5Video, Resizer) {
// via the 'state' object. Much easier to work this way - you don't // via the 'state' object. Much easier to work this way - you don't
// have to do repeated jQuery element selects. // have to do repeated jQuery element selects.
function _initialize(state) { function _initialize(state) {
var youTubeId, player; var youTubeId, player, duration;
// The function is called just once to apply pre-defined configurations // The function is called just once to apply pre-defined configurations
// by student before video starts playing. Waits until the video's // by student before video starts playing. Waits until the video's
...@@ -134,11 +134,20 @@ function (HTML5Video, Resizer) { ...@@ -134,11 +134,20 @@ function (HTML5Video, Resizer) {
_resize(state, videoWidth, videoHeight); _resize(state, videoWidth, videoHeight);
duration = state.videoPlayer.duration();
state.trigger( state.trigger(
'videoControl.updateVcrVidTime', 'videoControl.updateVcrVidTime',
{ {
time: 0, time: 0,
duration: state.videoPlayer.duration() duration: duration
}
);
state.trigger(
'videoProgressSlider.updateStartEndTimeRegion',
{
duration: duration
} }
); );
}, false); }, false);
...@@ -167,10 +176,11 @@ function (HTML5Video, Resizer) { ...@@ -167,10 +176,11 @@ function (HTML5Video, Resizer) {
_resize(state, videoWidth, videoHeight); _resize(state, videoWidth, videoHeight);
// We wait for metdata to arrive, before we request the update // We wait for metadata to arrive, before we request the update
// of the VCR video time. Metadata contains duration of the // of the VCR video time, and of the start-end time region.
// video. We wait for 2 seconds, and then abandon our attempts // Metadata contains duration of the video. We wait for 2
// to update the VCR video time using metadata. // seconds, and then abandon our attempts to update the VCR
// video time (and the start-end time region) using metadata.
(function () { (function () {
var checkInterval = window.setInterval( var checkInterval = window.setInterval(
checkForMetadata, 50 checkForMetadata, 50
...@@ -181,7 +191,8 @@ function (HTML5Video, Resizer) { ...@@ -181,7 +191,8 @@ function (HTML5Video, Resizer) {
function checkForMetadata() { function checkForMetadata() {
if (state.metadata && state.metadata[state.youtubeId()]) { if (state.metadata && state.metadata[state.youtubeId()]) {
console.log('[_initialize]: (youtube) .duration'); duration = state.videoPlayer.duration();
// After initialization, update the VCR with total time. // After initialization, update the VCR with total time.
// At this point only the metadata duration is available (not // At this point only the metadata duration is available (not
// very precise), but it is better than having 00:00:00 for // very precise), but it is better than having 00:00:00 for
...@@ -190,7 +201,14 @@ function (HTML5Video, Resizer) { ...@@ -190,7 +201,14 @@ function (HTML5Video, Resizer) {
'videoControl.updateVcrVidTime', 'videoControl.updateVcrVidTime',
{ {
time: 0, time: 0,
duration: state.videoPlayer.duration() duration: duration
}
);
state.trigger(
'videoProgressSlider.updateStartEndTimeRegion',
{
duration: duration
} }
); );
......
...@@ -113,10 +113,28 @@ function () { ...@@ -113,10 +113,28 @@ function () {
duration = params.duration; duration = params.duration;
} }
start = this.videoPlayer.startTime; start = this.config.startTime;
end = this.config.endTime;
// If end is set to null, then we set it to the end of the video. if (start > duration) {
end = this.videoPlayer.endTime || duration; start = 0;
} else {
if (this.currentPlayerMode === 'flash') {
start /= Number(this.speed);
}
}
// If end is set to null, or it is greater than the duration of the
// video, then we set it to the end of the video.
if (
end === null || end > duration
) {
end = duration;
} else if (end !== null) {
if (this.currentPlayerMode === 'flash') {
end /= Number(this.speed);
}
}
// Don't build a range if it takes up the whole slider. // Don't build a range if it takes up the whole slider.
if (start === 0 && end === duration) { if (start === 0 && end === 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