Commit 4b5f77aa by Valera Rozuvan Committed by Jay Zoldak

Added back old method of getting caption position for Flash video playback.

Because with speed changing the time also changes for Flash playback,
a different way to calculate the current time is needed than for HTML5
playback. I have added conditions for Flash and HTML5 video, and put
old method of calculating time for Flash.

I have tested it on the YouTube video ZwkTiUPN0mg. Both HTML5 mode and
Flash mode have proper video-captions syncing with this fix. NOTE: to view
YouTube video in Flash mode you either have to use an old browser (ex. Firefox
version 18) or hard code in source that state.currentPlayerMode = 'flash' (in
function _setPlayerMode(), file 01_initialize.js).
parent a6674312
...@@ -312,15 +312,34 @@ function () { ...@@ -312,15 +312,34 @@ function () {
var newIndex; var newIndex;
if (this.videoCaption.loaded) { if (this.videoCaption.loaded) {
time = Math.round(parseInt(time, 10) * 1000); // Current mode === 'flash' can only be for YouTube videos. So, we
// don't have to also check for videoType === 'youtube'.
if (this.currentPlayerMode === 'flash') {
// Total play time changes with speed change. Also there is
// a 250 ms delay we have to take into account.
time = Math.round(
Time.convert(time, this.speed, '1.0') * 1000 + 250
);
} else {
// Total play time remains constant when speed changes.
time = Math.round(parseInt(time, 10) * 1000);
}
newIndex = this.videoCaption.search(time); newIndex = this.videoCaption.search(time);
if (newIndex !== void 0 && this.videoCaption.currentIndex !== newIndex) { if (
newIndex !== void 0 &&
this.videoCaption.currentIndex !== newIndex
) {
if (this.videoCaption.currentIndex) { if (this.videoCaption.currentIndex) {
this.videoCaption.subtitlesEl.find('li.current').removeClass('current'); this.videoCaption.subtitlesEl
.find('li.current')
.removeClass('current');
} }
this.videoCaption.subtitlesEl.find("li[data-index='" + newIndex + "']").addClass('current'); this.videoCaption.subtitlesEl
.find("li[data-index='" + newIndex + "']")
.addClass('current');
this.videoCaption.currentIndex = newIndex; this.videoCaption.currentIndex = newIndex;
...@@ -333,9 +352,29 @@ function () { ...@@ -333,9 +352,29 @@ function () {
var time; var time;
event.preventDefault(); event.preventDefault();
time = parseInt($(event.target).data('start'), 10)/1000;
this.trigger('videoPlayer.onCaptionSeek', {'type': 'onCaptionSeek', 'time': time}); // Current mode === 'flash' can only be for YouTube videos. So, we
// don't have to also check for videoType === 'youtube'.
if (this.currentPlayerMode === 'flash') {
// Total play time changes with speed change. Also there is
// a 250 ms delay we have to take into account.
time = Math.round(
Time.convert(
$(event.target).data('start'), '1.0', this.speed
) / 1000
);
} else {
// Total play time remains constant when speed changes.
time = parseInt($(event.target).data('start'), 10)/1000;
}
this.trigger(
'videoPlayer.onCaptionSeek',
{
'type': 'onCaptionSeek',
'time': time
}
);
} }
function calculateOffset(element) { function calculateOffset(element) {
......
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