-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
I think the playbackRate computation is wrong when the media element needs to slow down. It's at least not symmetric when compared to the speed up but maybe that's intentional.
Let's imagine the media element has a currentTime
of 8.8 but it should be at the targetTime
of 8.2. The diff
computed as targetTime - currentTime
is then -0.6. That means the following code ...
media-element-syncer/src/media-element-syncer.js
Lines 78 to 82 in 9b53aa0
const rate = Math.max( | |
0, | |
((diff + this._correctionTime) / this._correctionTime) * | |
sourcePlaybackRate | |
); |
... evaluates like this:
const rate = Math.max(0, ((-0,6 + 0,5) / 0,5) * sourcePlaybackRate);
const rate = Math.max(0, -0,2 * sourcePlaybackRate);
const rate = 0;
I guess when the media element has to slow down it should instead be something like the following:
const rate = sourcePlaybackRate / ((Math.abs(-0,6) + 0,5) / 0,5);
const rate = sourcePlaybackRate / 2.2;
What about changing the rate computation to something like this?
const rate = diff > 0
? ((diff + this._correctionTime) / this._correctionTime) * sourcePlaybackRate
: sourcePlaybackRate / ((this._correctionTime - diff) / this._correctionTime);
Metadata
Metadata
Assignees
Labels
No labels