Skip to content

Commit

Permalink
Add a 10ms delay when rewinding a media pool video (#38576)
Browse files Browse the repository at this point in the history
* Add a 10ms delay when rewinding

* add additional context to hacky fix

(cherry picked from commit 811596e)
  • Loading branch information
erwinmombay committed Dec 9, 2022
1 parent 8ec16ec commit 8e08838
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions extensions/amp-story/1.0/media-pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -807,10 +807,19 @@ export class MediaPool {
return this.enqueueMediaElementTask_(poolMediaEl, new PauseTask()).then(
() => {
if (rewindToBeginning) {
this.enqueueMediaElementTask_(
/** @type {!PoolBoundElementDef} */ (poolMediaEl),
new SetCurrentTimeTask({currentTime: 0})
);
// We add a 10 second delay to rewinding as sometimes this causes an
// interlacing/glitch/frame jump when a new video is starting to play.
// A 0 delay isn't enough as we need to push the "seeking" event
// to the next tick of the event loop.
// NOTE: Please note that this is not an ideal solution and a bit hacky.
// The more ideal fix would be to fix the the navigations animation frames.
// See https://github.com/ampproject/amphtml/issues/38531
this.timer_.delay(() => {
this.enqueueMediaElementTask_(
/** @type {!PoolBoundElementDef} */ (poolMediaEl),
new SetCurrentTimeTask({currentTime: 0})
);
}, 10);
}
}
);
Expand Down

0 comments on commit 8e08838

Please sign in to comment.