diff options
author | Chocobozzz <me@florianbigard.com> | 2023-08-28 10:55:04 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-08-28 16:17:31 +0200 |
commit | 77b70702d2193d78bf6fbd07f0fc7335e34957f8 (patch) | |
tree | 1a0aed540054286c9a8b10c4890cc0f718e00458 /client/src/assets/player/shared/control-bar/time-tooltip.ts | |
parent | 7113f32a87bd6b2868154fed20bde1a1633c190e (diff) | |
download | PeerTube-77b70702d2193d78bf6fbd07f0fc7335e34957f8.tar.gz PeerTube-77b70702d2193d78bf6fbd07f0fc7335e34957f8.tar.zst PeerTube-77b70702d2193d78bf6fbd07f0fc7335e34957f8.zip |
Add video chapters support
Diffstat (limited to 'client/src/assets/player/shared/control-bar/time-tooltip.ts')
-rw-r--r-- | client/src/assets/player/shared/control-bar/time-tooltip.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/client/src/assets/player/shared/control-bar/time-tooltip.ts b/client/src/assets/player/shared/control-bar/time-tooltip.ts new file mode 100644 index 000000000..2ed4f9acd --- /dev/null +++ b/client/src/assets/player/shared/control-bar/time-tooltip.ts | |||
@@ -0,0 +1,20 @@ | |||
1 | import { timeToInt } from '@peertube/peertube-core-utils' | ||
2 | import videojs, { VideoJsPlayer } from 'video.js' | ||
3 | |||
4 | const TimeToolTip = videojs.getComponent('TimeTooltip') as any // FIXME: typings don't have write method | ||
5 | |||
6 | class TimeTooltip extends TimeToolTip { | ||
7 | |||
8 | write (timecode: string) { | ||
9 | const player: VideoJsPlayer = this.player() | ||
10 | |||
11 | if (player.usingPlugin('chapters')) { | ||
12 | const chapterTitle = player.chapters().getChapter(timeToInt(timecode)) | ||
13 | if (chapterTitle) return super.write(chapterTitle + '\r\n' + timecode) | ||
14 | } | ||
15 | |||
16 | return super.write(timecode) | ||
17 | } | ||
18 | } | ||
19 | |||
20 | videojs.registerComponent('TimeTooltip', TimeTooltip) | ||