🎥 Make videos programmatically with React
re-seek when another seek was added while seeking
Jonny Burgerd4ab50c5be15
diff --git a/packages/media-parser/src/seek-signal.ts b/packages/media-parser/src/seek-signal.tsindex 8a7d6ea628..c124f3fd59 100644--- a/packages/media-parser/src/seek-signal.ts+++ b/packages/media-parser/src/seek-signal.ts@@ -1,7 +1,7 @@export type SeekSignal = {seek: (seek: Seek) => void;getSeek: () => Seek | undefined;- clearSeekIfStillSame: (previousSeek: Seek) => void;+ clearSeekIfStillSame: (previousSeek: Seek) => {hasChanged: boolean};};type SeekToTime = {@@ -38,7 +38,10 @@ export const makeSeekSignal = (): SeekSignal => {clearSeekIfStillSame(previousSeek: Seek) {if (seek === previousSeek) {seek = undefined;+ return {hasChanged: false};}++ return {hasChanged: true};},};};diff --git a/packages/media-parser/src/work-on-seek-request.ts b/packages/media-parser/src/work-on-seek-request.tsindex 54ec487863..f0606d38c8 100644--- a/packages/media-parser/src/work-on-seek-request.ts+++ b/packages/media-parser/src/work-on-seek-request.ts@@ -36,7 +36,15 @@ export const workOnSeekRequest = async (state: ParserState) => {if (resolution.type === 'do-seek') {await performSeek({state, seekTo: resolution.byte});- state.controller._internals.seekSignal.clearSeekIfStillSame(seek);+ const {hasChanged} =+ state.controller._internals.seekSignal.clearSeekIfStillSame(seek);+ if (hasChanged) {+ Log.trace(+ state.logLevel,+ `Seek request has changed while seeking, seeking again`,+ );+ await workOnSeekRequest(state);+ }}if (resolution.type === 'invalid') {