aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/peertube-player-manager.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/peertube-player-manager.ts')
-rw-r--r--client/src/assets/player/peertube-player-manager.ts42
1 files changed, 35 insertions, 7 deletions
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts
index b071a0938..6f0b804cd 100644
--- a/client/src/assets/player/peertube-player-manager.ts
+++ b/client/src/assets/player/peertube-player-manager.ts
@@ -33,13 +33,14 @@ import { getStoredP2PEnabled } from './peertube-player-local-storage'
33import { 33import {
34 NextPreviousVideoButtonOptions, 34 NextPreviousVideoButtonOptions,
35 P2PMediaLoaderPluginOptions, 35 P2PMediaLoaderPluginOptions,
36 PeerTubeLinkButtonOptions,
36 PlaylistPluginOptions, 37 PlaylistPluginOptions,
37 UserWatching, 38 UserWatching,
38 VideoJSCaption, 39 VideoJSCaption,
39 VideoJSPluginOptions 40 VideoJSPluginOptions
40} from './peertube-videojs-typings' 41} from './peertube-videojs-typings'
41import { TranslationsManager } from './translations-manager' 42import { TranslationsManager } from './translations-manager'
42import { buildVideoLink, buildVideoOrPlaylistEmbed, getRtcConfig, isIOS, isSafari } from './utils' 43import { buildVideoLink, buildVideoOrPlaylistEmbed, decorateVideoLink, getRtcConfig, isIOS, isSafari } from './utils'
43 44
44// Change 'Playback Rate' to 'Speed' (smaller for our settings menu) 45// Change 'Playback Rate' to 'Speed' (smaller for our settings menu)
45(videojs.getComponent('PlaybackRateMenuButton') as any).prototype.controlText_ = 'Speed' 46(videojs.getComponent('PlaybackRateMenuButton') as any).prototype.controlText_ = 'Speed'
@@ -110,6 +111,7 @@ export interface CommonOptions extends CustomizationOptions {
110 videoCaptions: VideoJSCaption[] 111 videoCaptions: VideoJSCaption[]
111 112
112 videoUUID: string 113 videoUUID: string
114 videoShortUUID: string
113 115
114 userWatching?: UserWatching 116 userWatching?: UserWatching
115 117
@@ -175,7 +177,13 @@ export class PeertubePlayerManager {
175 PeertubePlayerManager.alreadyPlayed = true 177 PeertubePlayerManager.alreadyPlayed = true
176 }) 178 })
177 179
178 self.addContextMenu(mode, player, options.common.embedUrl, options.common.embedTitle) 180 self.addContextMenu({
181 mode,
182 player,
183 videoShortUUID: options.common.videoShortUUID,
184 videoEmbedUrl: options.common.embedUrl,
185 videoEmbedTitle: options.common.embedTitle
186 })
179 187
180 player.bezels() 188 player.bezels()
181 player.stats({ 189 player.stats({
@@ -218,7 +226,13 @@ export class PeertubePlayerManager {
218 videojs(newVideoElement, videojsOptions, function (this: videojs.Player) { 226 videojs(newVideoElement, videojsOptions, function (this: videojs.Player) {
219 const player = this 227 const player = this
220 228
221 self.addContextMenu(mode, player, options.common.embedUrl, options.common.embedTitle) 229 self.addContextMenu({
230 mode,
231 player,
232 videoShortUUID: options.common.videoShortUUID,
233 videoEmbedUrl: options.common.embedUrl,
234 videoEmbedTitle: options.common.embedTitle
235 })
222 236
223 PeertubePlayerManager.onPlayerChange(player) 237 PeertubePlayerManager.onPlayerChange(player)
224 }) 238 })
@@ -295,6 +309,8 @@ export class PeertubePlayerManager {
295 309
296 controlBar: { 310 controlBar: {
297 children: this.getControlBarChildren(mode, { 311 children: this.getControlBarChildren(mode, {
312 videoShortUUID: commonOptions.videoShortUUID,
313
298 captions: commonOptions.captions, 314 captions: commonOptions.captions,
299 peertubeLink: commonOptions.peertubeLink, 315 peertubeLink: commonOptions.peertubeLink,
300 theaterButton: commonOptions.theaterButton, 316 theaterButton: commonOptions.theaterButton,
@@ -409,6 +425,8 @@ export class PeertubePlayerManager {
409 } 425 }
410 426
411 private static getControlBarChildren (mode: PlayerMode, options: { 427 private static getControlBarChildren (mode: PlayerMode, options: {
428 videoShortUUID: string
429
412 peertubeLink: boolean 430 peertubeLink: boolean
413 theaterButton: boolean 431 theaterButton: boolean
414 captions: boolean 432 captions: boolean
@@ -497,7 +515,7 @@ export class PeertubePlayerManager {
497 515
498 if (options.peertubeLink === true) { 516 if (options.peertubeLink === true) {
499 Object.assign(children, { 517 Object.assign(children, {
500 'peerTubeLinkButton': {} 518 'peerTubeLinkButton': { shortUUID: options.videoShortUUID } as PeerTubeLinkButtonOptions
501 }) 519 })
502 } 520 }
503 521
@@ -514,7 +532,15 @@ export class PeertubePlayerManager {
514 return children 532 return children
515 } 533 }
516 534
517 private static addContextMenu (mode: PlayerMode, player: videojs.Player, videoEmbedUrl: string, videoEmbedTitle: string) { 535 private static addContextMenu (options: {
536 mode: PlayerMode
537 player: videojs.Player
538 videoShortUUID: string
539 videoEmbedUrl: string
540 videoEmbedTitle: string
541 }) {
542 const { mode, player, videoEmbedTitle, videoEmbedUrl, videoShortUUID } = options
543
518 const content = () => { 544 const content = () => {
519 const isLoopEnabled = player.options_['loop'] 545 const isLoopEnabled = player.options_['loop']
520 const items = [ 546 const items = [
@@ -528,13 +554,15 @@ export class PeertubePlayerManager {
528 { 554 {
529 label: player.localize('Copy the video URL'), 555 label: player.localize('Copy the video URL'),
530 listener: function () { 556 listener: function () {
531 copyToClipboard(buildVideoLink()) 557 copyToClipboard(buildVideoLink({ shortUUID: videoShortUUID }))
532 } 558 }
533 }, 559 },
534 { 560 {
535 label: player.localize('Copy the video URL at the current time'), 561 label: player.localize('Copy the video URL at the current time'),
536 listener: function (this: videojs.Player) { 562 listener: function (this: videojs.Player) {
537 copyToClipboard(buildVideoLink({ startTime: this.currentTime() })) 563 const url = buildVideoLink({ shortUUID: videoShortUUID })
564
565 copyToClipboard(decorateVideoLink({ url, startTime: this.currentTime() }))
538 } 566 }
539 }, 567 },
540 { 568 {