Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor VideoPlayer component to improve rewind and forward function #106

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions packages/media-console/src/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,38 @@
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);


Check failure on line 397 in packages/media-console/src/VideoPlayer.tsx

View workflow job for this annotation

GitHub Actions / build

Delete `⏎`
let timeoutId: ReturnType<typeof setTimeout> | null = null;

Check failure on line 399 in packages/media-console/src/VideoPlayer.tsx

View workflow job for this annotation

GitHub Actions / build

Delete `··`

Check warning on line 399 in packages/media-console/src/VideoPlayer.tsx

View workflow job for this annotation

GitHub Actions / build

Trailing spaces not allowed
let accumulatedRewindTime = 0;

Check failure on line 400 in packages/media-console/src/VideoPlayer.tsx

View workflow job for this annotation

GitHub Actions / build

Delete `·`

Check warning on line 400 in packages/media-console/src/VideoPlayer.tsx

View workflow job for this annotation

GitHub Actions / build

Trailing spaces not allowed
const rewind = () => {
if (currentTime === 0) return;

Check warning on line 402 in packages/media-console/src/VideoPlayer.tsx

View workflow job for this annotation

GitHub Actions / build

Expected { after 'if' condition
if(timeoutId) clearTimeout(timeoutId);

Check warning on line 403 in packages/media-console/src/VideoPlayer.tsx

View workflow job for this annotation

GitHub Actions / build

Expected space(s) after "if"

Check failure on line 403 in packages/media-console/src/VideoPlayer.tsx

View workflow job for this annotation

GitHub Actions / build

Insert `·`

Check warning on line 403 in packages/media-console/src/VideoPlayer.tsx

View workflow job for this annotation

GitHub Actions / build

Expected { after 'if' condition
accumulatedRewindTime += rewindTime

Check failure on line 404 in packages/media-console/src/VideoPlayer.tsx

View workflow job for this annotation

GitHub Actions / build

Insert `;`

Check failure on line 404 in packages/media-console/src/VideoPlayer.tsx

View workflow job for this annotation

GitHub Actions / build

Missing semicolon

timeoutId = setTimeout(() => {
videoRef?.current?.seek(currentTime - accumulatedRewindTime);

Check failure on line 407 in packages/media-console/src/VideoPlayer.tsx

View workflow job for this annotation

GitHub Actions / build

Delete `··`

accumulatedRewindTime = 0;

Check failure on line 409 in packages/media-console/src/VideoPlayer.tsx

View workflow job for this annotation

GitHub Actions / build

Delete `··`

timeoutId = null;

Check failure on line 411 in packages/media-console/src/VideoPlayer.tsx

View workflow job for this annotation

GitHub Actions / build

Replace `········` with `······`
}, 700);
}

Check failure on line 413 in packages/media-console/src/VideoPlayer.tsx

View workflow job for this annotation

GitHub Actions / build

Insert `;`

let accumulatedForwardTime = 0;
const forward = () => {
if (currentTime === 0) return;

Check warning on line 417 in packages/media-console/src/VideoPlayer.tsx

View workflow job for this annotation

GitHub Actions / build

Expected { after 'if' condition
if(timeoutId) clearTimeout(timeoutId);

Check warning on line 418 in packages/media-console/src/VideoPlayer.tsx

View workflow job for this annotation

GitHub Actions / build

Expected space(s) after "if"

Check warning on line 418 in packages/media-console/src/VideoPlayer.tsx

View workflow job for this annotation

GitHub Actions / build

Expected { after 'if' condition
accumulatedForwardTime += rewindTime
timeoutId = setTimeout(() => {
videoRef?.current?.seek(currentTime + accumulatedForwardTime);

accumulatedForwardTime = 0;

timeoutId = null;
}, 700);
}

return (
<PlatformSupport
showControls={showControls}
Expand Down Expand Up @@ -439,12 +471,8 @@
togglePlayPause={togglePlayPause}
resetControlTimeout={resetControlTimeout}
showControls={showControls}
onPressRewind={() =>
videoRef?.current?.seek(currentTime - rewindTime)
}
onPressForward={() =>
videoRef?.current?.seek(currentTime + rewindTime)
}
onPressRewind={rewind}
onPressForward={forward}
/>
<BottomControls
animations={animations}
Expand Down
Loading