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.ts67
1 files changed, 42 insertions, 25 deletions
diff --git a/client/src/assets/player/peertube-player.ts b/client/src/assets/player/peertube-player.ts
index d204b9703..b604097fa 100644
--- a/client/src/assets/player/peertube-player.ts
+++ b/client/src/assets/player/peertube-player.ts
@@ -12,6 +12,7 @@ import './peertube-videojs-plugin'
12import './peertube-load-progress-bar' 12import './peertube-load-progress-bar'
13import { videojsUntyped } from './peertube-videojs-typings' 13import { videojsUntyped } from './peertube-videojs-typings'
14import { buildVideoEmbed, buildVideoLink, copyToClipboard } from './utils' 14import { buildVideoEmbed, buildVideoLink, copyToClipboard } from './utils'
15import { is18nLocale, isDefaultLocale } from '../../../../shared/models/i18n/i18n'
15 16
16// Change 'Playback Rate' to 'Speed' (smaller for our settings menu) 17// Change 'Playback Rate' to 'Speed' (smaller for our settings menu)
17videojsUntyped.getComponent('PlaybackRateMenuButton').prototype.controlText_ = 'Speed' 18videojsUntyped.getComponent('PlaybackRateMenuButton').prototype.controlText_ = 'Speed'
@@ -20,7 +21,6 @@ function getVideojsOptions (options: {
20 autoplay: boolean, 21 autoplay: boolean,
21 playerElement: HTMLVideoElement, 22 playerElement: HTMLVideoElement,
22 videoViewUrl: string, 23 videoViewUrl: string,
23 videoEmbedUrl: string,
24 videoDuration: number, 24 videoDuration: number,
25 videoFiles: VideoFile[], 25 videoFiles: VideoFile[],
26 enableHotkeys: boolean, 26 enableHotkeys: boolean,
@@ -43,29 +43,6 @@ function getVideojsOptions (options: {
43 videoViewUrl: options.videoViewUrl, 43 videoViewUrl: options.videoViewUrl,
44 videoDuration: options.videoDuration, 44 videoDuration: options.videoDuration,
45 startTime: options.startTime 45 startTime: options.startTime
46 },
47 contextmenuUI: {
48 content: [
49 {
50 label: 'Copy the video URL',
51 listener: function () {
52 copyToClipboard(buildVideoLink())
53 }
54 },
55 {
56 label: 'Copy the video URL at the current time',
57 listener: function () {
58 const player = this
59 copyToClipboard(buildVideoLink(player.currentTime()))
60 }
61 },
62 {
63 label: 'Copy embed code',
64 listener: () => {
65 copyToClipboard(buildVideoEmbed(options.videoEmbedUrl))
66 }
67 }
68 ]
69 } 46 }
70 }, 47 },
71 controlBar: { 48 controlBar: {
@@ -135,4 +112,44 @@ function getControlBarChildren (options: {
135 return children 112 return children
136} 113}
137 114
138export { getVideojsOptions } 115function addContextMenu (player: any, videoEmbedUrl: string) {
116 console.log(videoEmbedUrl)
117
118 player.contextmenuUI({
119 content: [
120 {
121 label: player.localize('Copy the video URL'),
122 listener: function () {
123 copyToClipboard(buildVideoLink())
124 }
125 },
126 {
127 label: player.localize('Copy the video URL at the current time'),
128 listener: function () {
129 const player = this
130 copyToClipboard(buildVideoLink(player.currentTime()))
131 }
132 },
133 {
134 label: player.localize('Copy embed code'),
135 listener: () => {
136 copyToClipboard(buildVideoEmbed(videoEmbedUrl))
137 }
138 }
139 ]
140 })
141}
142
143function loadLocale (serverUrl: string, videojs: any, locale: string) {
144 if (!is18nLocale(locale) || isDefaultLocale(locale)) return undefined
145
146 return fetch(serverUrl + '/client/locales/' + locale + '/player.json')
147 .then(res => res.json())
148 .then(json => videojs.addLanguage(locale, json))
149}
150
151export {
152 loadLocale,
153 getVideojsOptions,
154 addContextMenu
155}