Skip to content

Commit

Permalink
feat: update transcript logic for improved playback experience #2503
Browse files Browse the repository at this point in the history
  • Loading branch information
KVV94 committed Dec 5, 2024
1 parent 324b004 commit c3e2dd3
Showing 1 changed file with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,27 @@ export const Viewer = ({ transcriptString }: Props) => {

return (
<Wrapper ref={wrapperRef}>
{transcriptData.map((i) => {
const start = secondsToMediaTime(i.start)

const isActive = i.start < currentTime && currentTime < i.end

return (
<Paragraph
key={`${i.start}-${i.end}`}
ref={isActive ? activeRef : null}
active={isActive}
start={start}
text={i.text}
/>
)
})}
{transcriptData[0].start > currentTime ? (
<Paragraph active={false} start={secondsToMediaTime(transcriptData[0].start)} text={transcriptData[0].text} />
) : (
<>
{transcriptData.map((i) => {
const start = secondsToMediaTime(i.start)

const isActive = i.start < currentTime && currentTime < i.end

return i.start <= currentTime + 5 ? (
<Paragraph
key={`${i.start}-${i.end}`}
ref={isActive ? activeRef : null}
active={isActive}
start={start}
text={i.text}
/>
) : null
})}
</>
)}
</Wrapper>
)
}
Expand Down

0 comments on commit c3e2dd3

Please sign in to comment.