cladera / videojs-offset

VideoJS plugin for play a segment of a video.
MIT License
64 stars 43 forks source link

Remaining time not updated correctly #24

Closed zetisam closed 6 years ago

zetisam commented 7 years ago

Description

The remaining time isn't correctly updated when using this plugin. It stays equal to the duration of the video for the entire length.

Steps to reproduce

set remainingTimeDisplay to true and enable the plugin.

Results

Expected

Remaining time should count towards zero while playing

Actual

Remaining time remains equal to duration.

Additional Information

VideoJS version: v6.2.5 Offset plugin version: 2.0.0-beta.0

Cause and Fix

I don't want to go through the hassle to set up development environment etc.. but the problem is caused by the check on line 91 https://github.com/cladera/videojs-offset/blob/master/src/js/index.js#L91

You've checking if currentTime is smaller than the startOffset, and if so currentTime is set to 0. If currentTime is zero, the remaining time is equal to the duration.

But currentTime already takes into account the startOffset. If currentTime is at 0, it actually is at startOffset in the full video, so you don't need the additional check.

So if you remove lines 91 through 93

if (curr < this._offsetStart) {
    curr = 0;
}

This will work.

cladera commented 7 years ago

Thanks @zetisam I'll take a look