aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/peertube-player.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/peertube-player.ts')
-rw-r--r--client/src/assets/player/peertube-player.ts25
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'
11import './peertube-videojs-plugin' 11import './peertube-videojs-plugin'
12import './peertube-load-progress-bar' 12import './peertube-load-progress-bar'
13import './theater-button' 13import './theater-button'
14import { videojsUntyped } from './peertube-videojs-typings' 14import { VideoJSCaption, videojsUntyped } from './peertube-videojs-typings'
15import { buildVideoEmbed, buildVideoLink, copyToClipboard } from './utils' 15import { buildVideoEmbed, buildVideoLink, copyToClipboard } from './utils'
16import { getCompleteLocale, getShortLocale, is18nLocale, isDefaultLocale } from '../../../../shared/models/i18n/i18n' 16import { 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)
19videojsUntyped.getComponent('PlaybackRateMenuButton').prototype.controlText_ = 'Speed' 19videojsUntyped.getComponent('PlaybackRateMenuButton').prototype.controlText_ = 'Speed'
20// Change Captions to Subtitles/CC
21videojsUntyped.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)
23videojsUntyped.getComponent('CaptionsButton').prototype.label_ = ' '
20 24
21function getVideojsOptions (options: { 25function 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
72function getControlBarChildren (options: { 80function 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