diff options
author | Chocobozzz <me@florianbigard.com> | 2018-07-13 18:21:19 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-16 11:50:08 +0200 |
commit | 16f7022b06fb76c0b00c23c970bc8df605b0ec63 (patch) | |
tree | 0677c72b449485dcaa87ee2b470dfb1a8124b9e0 /client/src/assets/player/peertube-player.ts | |
parent | 40e87e9ecc54e3513fb586928330a7855eb192c6 (diff) | |
download | PeerTube-16f7022b06fb76c0b00c23c970bc8df605b0ec63.tar.gz PeerTube-16f7022b06fb76c0b00c23c970bc8df605b0ec63.tar.zst PeerTube-16f7022b06fb76c0b00c23c970bc8df605b0ec63.zip |
Handle subtitles in player
Diffstat (limited to 'client/src/assets/player/peertube-player.ts')
-rw-r--r-- | client/src/assets/player/peertube-player.ts | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/client/src/assets/player/peertube-player.ts b/client/src/assets/player/peertube-player.ts index baae740fe..bf02ce91c 100644 --- a/client/src/assets/player/peertube-player.ts +++ b/client/src/assets/player/peertube-player.ts | |||
@@ -11,12 +11,16 @@ import './webtorrent-info-button' | |||
11 | import './peertube-videojs-plugin' | 11 | import './peertube-videojs-plugin' |
12 | import './peertube-load-progress-bar' | 12 | import './peertube-load-progress-bar' |
13 | import './theater-button' | 13 | import './theater-button' |
14 | import { videojsUntyped } from './peertube-videojs-typings' | 14 | import { VideoJSCaption, videojsUntyped } from './peertube-videojs-typings' |
15 | import { buildVideoEmbed, buildVideoLink, copyToClipboard } from './utils' | 15 | import { buildVideoEmbed, buildVideoLink, copyToClipboard } from './utils' |
16 | import { getCompleteLocale, getShortLocale, is18nLocale, isDefaultLocale } from '../../../../shared/models/i18n/i18n' | 16 | import { getCompleteLocale, getShortLocale, is18nLocale, isDefaultLocale } from '../../../../shared/models/i18n/i18n' |
17 | 17 | ||
18 | // Change 'Playback Rate' to 'Speed' (smaller for our settings menu) | 18 | // Change 'Playback Rate' to 'Speed' (smaller for our settings menu) |
19 | videojsUntyped.getComponent('PlaybackRateMenuButton').prototype.controlText_ = 'Speed' | 19 | videojsUntyped.getComponent('PlaybackRateMenuButton').prototype.controlText_ = 'Speed' |
20 | // Change Captions to Subtitles/CC | ||
21 | videojsUntyped.getComponent('CaptionsButton').prototype.controlText_ = 'Subtitles/CC' | ||
22 | // We just want to display 'Off' instead of 'captions off', keep a space so the variable == true (hacky I know) | ||
23 | videojsUntyped.getComponent('CaptionsButton').prototype.label_ = ' ' | ||
20 | 24 | ||
21 | function getVideojsOptions (options: { | 25 | function getVideojsOptions (options: { |
22 | autoplay: boolean, | 26 | autoplay: boolean, |
@@ -30,11 +34,14 @@ function getVideojsOptions (options: { | |||
30 | poster: string, | 34 | poster: string, |
31 | startTime: number | 35 | startTime: number |
32 | theaterMode: boolean, | 36 | theaterMode: boolean, |
37 | videoCaptions: VideoJSCaption[], | ||
33 | controls?: boolean, | 38 | controls?: boolean, |
34 | muted?: boolean, | 39 | muted?: boolean, |
35 | loop?: boolean | 40 | loop?: boolean |
36 | }) { | 41 | }) { |
37 | const videojsOptions = { | 42 | const videojsOptions = { |
43 | // We don't use text track settings for now | ||
44 | textTrackSettings: false, | ||
38 | controls: options.controls !== undefined ? options.controls : true, | 45 | controls: options.controls !== undefined ? options.controls : true, |
39 | muted: options.controls !== undefined ? options.muted : false, | 46 | muted: options.controls !== undefined ? options.muted : false, |
40 | loop: options.loop !== undefined ? options.loop : false, | 47 | loop: options.loop !== undefined ? options.loop : false, |
@@ -45,6 +52,7 @@ function getVideojsOptions (options: { | |||
45 | plugins: { | 52 | plugins: { |
46 | peertube: { | 53 | peertube: { |
47 | autoplay: options.autoplay, // Use peertube plugin autoplay because we get the file by webtorrent | 54 | autoplay: options.autoplay, // Use peertube plugin autoplay because we get the file by webtorrent |
55 | videoCaptions: options.videoCaptions, | ||
48 | videoFiles: options.videoFiles, | 56 | videoFiles: options.videoFiles, |
49 | playerElement: options.playerElement, | 57 | playerElement: options.playerElement, |
50 | videoViewUrl: options.videoViewUrl, | 58 | videoViewUrl: options.videoViewUrl, |
@@ -71,8 +79,16 @@ function getVideojsOptions (options: { | |||
71 | 79 | ||
72 | function getControlBarChildren (options: { | 80 | function getControlBarChildren (options: { |
73 | peertubeLink: boolean | 81 | peertubeLink: boolean |
74 | theaterMode: boolean | 82 | theaterMode: boolean, |
83 | videoCaptions: VideoJSCaption[] | ||
75 | }) { | 84 | }) { |
85 | const settingEntries = [] | ||
86 | |||
87 | // Keep an order | ||
88 | settingEntries.push('playbackRateMenuButton') | ||
89 | if (options.videoCaptions.length !== 0) settingEntries.push('captionsButton') | ||
90 | settingEntries.push('resolutionMenuButton') | ||
91 | |||
76 | const children = { | 92 | const children = { |
77 | 'playToggle': {}, | 93 | 'playToggle': {}, |
78 | 'currentTimeDisplay': {}, | 94 | 'currentTimeDisplay': {}, |
@@ -102,10 +118,7 @@ function getControlBarChildren (options: { | |||
102 | setup: { | 118 | setup: { |
103 | maxHeightOffset: 40 | 119 | maxHeightOffset: 40 |
104 | }, | 120 | }, |
105 | entries: [ | 121 | entries: settingEntries |
106 | 'resolutionMenuButton', | ||
107 | 'playbackRateMenuButton' | ||
108 | ] | ||
109 | } | 122 | } |
110 | } | 123 | } |
111 | 124 | ||