Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Add chapter cache to time tooltip

Chocobozzz078c97b35772
diff --git a/client/src/assets/player/shared/control-bar/time-tooltip.ts b/client/src/assets/player/shared/control-bar/time-tooltip.ts
index 2ed4f9acdb..44ad5106b7 100644
--- a/client/src/assets/player/shared/control-bar/time-tooltip.ts
+++ b/client/src/assets/player/shared/control-bar/time-tooltip.ts
@@ -4,13 +4,19 @@ import videojs, { VideoJsPlayer } from 'video.js'
const TimeToolTip = videojs.getComponent('TimeTooltip') as any // FIXME: typings don't have write method
class TimeTooltip extends TimeToolTip {
+ private currentTimecode: string
+ private currentChapterTitle: string
write (timecode: string) {
const player: VideoJsPlayer = this.player()
if (player.usingPlugin('chapters')) {
- const chapterTitle = player.chapters().getChapter(timeToInt(timecode))
- if (chapterTitle) return super.write(chapterTitle + '\r\n' + timecode)
+ if (timecode === this.currentTimecode) return
+
+ this.currentTimecode = timecode
+ this.currentChapterTitle = player.chapters().getChapter(timeToInt(this.currentTimecode))
+
+ if (this.currentChapterTitle) return super.write(this.currentChapterTitle + '\r\n' + this.currentTimecode)
}
return super.write(timecode)