diff options
Diffstat (limited to 'client/src/assets/player/peertube-videojs-plugin.ts')
-rw-r--r-- | client/src/assets/player/peertube-videojs-plugin.ts | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts index 57c894ee6..3f6fc4cc6 100644 --- a/client/src/assets/player/peertube-videojs-plugin.ts +++ b/client/src/assets/player/peertube-videojs-plugin.ts | |||
@@ -3,7 +3,7 @@ import * as WebTorrent from 'webtorrent' | |||
3 | import { VideoFile } from '../../../../shared/models/videos/video.model' | 3 | import { VideoFile } from '../../../../shared/models/videos/video.model' |
4 | import { renderVideo } from './video-renderer' | 4 | import { renderVideo } from './video-renderer' |
5 | import './settings-menu-button' | 5 | import './settings-menu-button' |
6 | import { PeertubePluginOptions, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' | 6 | import { PeertubePluginOptions, VideoJSCaption, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' |
7 | import { isMobile, videoFileMaxByResolution, videoFileMinByResolution } from './utils' | 7 | import { isMobile, videoFileMaxByResolution, videoFileMinByResolution } from './utils' |
8 | import * as CacheChunkStore from 'cache-chunk-store' | 8 | import * as CacheChunkStore from 'cache-chunk-store' |
9 | import { PeertubeChunkStore } from './peertube-chunk-store' | 9 | import { PeertubeChunkStore } from './peertube-chunk-store' |
@@ -54,6 +54,7 @@ class PeerTubePlugin extends Plugin { | |||
54 | private player: any | 54 | private player: any |
55 | private currentVideoFile: VideoFile | 55 | private currentVideoFile: VideoFile |
56 | private torrent: WebTorrent.Torrent | 56 | private torrent: WebTorrent.Torrent |
57 | private videoCaptions: VideoJSCaption[] | ||
57 | private renderer | 58 | private renderer |
58 | private fakeRenderer | 59 | private fakeRenderer |
59 | private autoResolution = true | 60 | private autoResolution = true |
@@ -79,6 +80,7 @@ class PeerTubePlugin extends Plugin { | |||
79 | this.videoFiles = options.videoFiles | 80 | this.videoFiles = options.videoFiles |
80 | this.videoViewUrl = options.videoViewUrl | 81 | this.videoViewUrl = options.videoViewUrl |
81 | this.videoDuration = options.videoDuration | 82 | this.videoDuration = options.videoDuration |
83 | this.videoCaptions = options.videoCaptions | ||
82 | 84 | ||
83 | this.savePlayerSrcFunction = this.player.src | 85 | this.savePlayerSrcFunction = this.player.src |
84 | // Hack to "simulate" src link in video.js >= 6 | 86 | // Hack to "simulate" src link in video.js >= 6 |
@@ -421,6 +423,8 @@ class PeerTubePlugin extends Plugin { | |||
421 | 423 | ||
422 | this.initSmoothProgressBar() | 424 | this.initSmoothProgressBar() |
423 | 425 | ||
426 | this.initCaptions() | ||
427 | |||
424 | this.alterInactivity() | 428 | this.alterInactivity() |
425 | 429 | ||
426 | if (this.autoplay === true) { | 430 | if (this.autoplay === true) { |
@@ -581,7 +585,7 @@ class PeerTubePlugin extends Plugin { | |||
581 | this.player.options_.inactivityTimeout = 0 | 585 | this.player.options_.inactivityTimeout = 0 |
582 | } | 586 | } |
583 | const enableInactivity = () => { | 587 | const enableInactivity = () => { |
584 | this.player.options_.inactivityTimeout = saveInactivityTimeout | 588 | // this.player.options_.inactivityTimeout = saveInactivityTimeout |
585 | } | 589 | } |
586 | 590 | ||
587 | const settingsDialog = this.player.children_.find(c => c.name_ === 'SettingsDialog') | 591 | const settingsDialog = this.player.children_.find(c => c.name_ === 'SettingsDialog') |
@@ -611,6 +615,18 @@ class PeerTubePlugin extends Plugin { | |||
611 | } | 615 | } |
612 | } | 616 | } |
613 | 617 | ||
618 | private initCaptions () { | ||
619 | for (const caption of this.videoCaptions) { | ||
620 | this.player.addRemoteTextTrack({ | ||
621 | kind: 'captions', | ||
622 | label: caption.label, | ||
623 | language: caption.language, | ||
624 | id: caption.language, | ||
625 | src: caption.src | ||
626 | }, false) | ||
627 | } | ||
628 | } | ||
629 | |||
614 | // Thanks: https://github.com/videojs/video.js/issues/4460#issuecomment-312861657 | 630 | // Thanks: https://github.com/videojs/video.js/issues/4460#issuecomment-312861657 |
615 | private initSmoothProgressBar () { | 631 | private initSmoothProgressBar () { |
616 | const SeekBar = videojsUntyped.getComponent('SeekBar') | 632 | const SeekBar = videojsUntyped.getComponent('SeekBar') |