Skip to content

Commit

Permalink
Merge pull request #2504 from KVV94/master
Browse files Browse the repository at this point in the history
feat: update transcript logic for improved playback experience
  • Loading branch information
Rassl authored Dec 6, 2024
2 parents 31c19de + d8b44c2 commit 8713dec
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 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
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const Transcript = () => {
return () => clearInterval(interval)
}, [playerRef, setCurrentTime])

return currentTime ? (
return (
<Wrapper>
<Flex className="heading">Transcript</Flex>
{clips.map((clip) => {
Expand All @@ -67,7 +67,7 @@ export const Transcript = () => {
return null
})}
</Wrapper>
) : null
)
}

const Wrapper = styled(Flex)`
Expand Down

0 comments on commit 8713dec

Please sign in to comment.