Skip to content

Commit

Permalink
add buffer to both sides, handle negative end times
Browse files Browse the repository at this point in the history
  • Loading branch information
t3dotgg committed Dec 14, 2023
1 parent 6b85432 commit 9402579
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/app/(core)/v/[slug]/player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ const initializePlayer = (
};
};

// Number of seconds to pad on each side of exported CSV
const EXPORT_BUFFER = 10;

export const VodPlayer = (props: { id: string; vod: VOD }) => {
const [player, setPlayer] = useState<Player | null>(null);

Expand All @@ -95,13 +98,17 @@ export const VodPlayer = (props: { id: string; vod: VOD }) => {
totalSeconds: 0,
});
const csv = mockedMarkers.map((marker, id) => {
const endTime =
let endTime =
(mockedMarkers[id + 1]?.position_seconds ??
(videoDuration as duration.Duration)?.asSeconds?.()) -
offset.totalSeconds;

endTime += EXPORT_BUFFER;

if (endTime < 0) endTime = 1;

const startTime = Math.max(
marker.position_seconds - offset.totalSeconds,
marker.position_seconds - offset.totalSeconds - EXPORT_BUFFER,
0
);

Expand Down

1 comment on commit 9402579

@vercel
Copy link

@vercel vercel bot commented on 9402579 Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.