aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player')
-rw-r--r--client/src/assets/player/peertube-player-manager.ts65
1 files changed, 38 insertions, 27 deletions
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts
index 119dec379..018845a54 100644
--- a/client/src/assets/player/peertube-player-manager.ts
+++ b/client/src/assets/player/peertube-player-manager.ts
@@ -1,6 +1,6 @@
1import 'videojs-hotkeys/videojs.hotkeys' 1import 'videojs-hotkeys/videojs.hotkeys'
2import 'videojs-dock' 2import 'videojs-dock'
3import 'videojs-contextmenu-ui' 3import 'videojs-contextmenu-pt'
4import 'videojs-contrib-quality-levels' 4import 'videojs-contrib-quality-levels'
5import './upnext/end-card' 5import './upnext/end-card'
6import './upnext/upnext-plugin' 6import './upnext/upnext-plugin'
@@ -122,7 +122,6 @@ export type PeertubePlayerManagerOptions = {
122export class PeertubePlayerManager { 122export class PeertubePlayerManager {
123 private static playerElementClassName: string 123 private static playerElementClassName: string
124 private static onPlayerChange: (player: videojs.Player) => void 124 private static onPlayerChange: (player: videojs.Player) => void
125
126 private static alreadyPlayed = false 125 private static alreadyPlayed = false
127 126
128 static initState () { 127 static initState () {
@@ -497,36 +496,48 @@ export class PeertubePlayerManager {
497 } 496 }
498 497
499 private static addContextMenu (mode: PlayerMode, player: videojs.Player, videoEmbedUrl: string, videoEmbedTitle: string) { 498 private static addContextMenu (mode: PlayerMode, player: videojs.Player, videoEmbedUrl: string, videoEmbedTitle: string) {
500 const content = [ 499 const content = () => {
501 { 500 const isLoopEnabled = player.options_['loop']
502 label: player.localize('Copy the video URL'), 501 const items = [
503 listener: function () { 502 {
504 copyToClipboard(buildVideoLink()) 503 label: isLoopEnabled ? player.localize('Stop playing in loop') : player.localize('Play in loop'),
505 } 504 listener: function () {
506 }, 505 player.options_['loop'] = !isLoopEnabled
507 { 506 }
508 label: player.localize('Copy the video URL at the current time'), 507 },
509 listener: function (this: videojs.Player) { 508 {
510 copyToClipboard(buildVideoLink({ startTime: this.currentTime() })) 509 label: player.localize('Copy the video URL'),
511 } 510 listener: function () {
512 }, 511 copyToClipboard(buildVideoLink())
513 { 512 }
514 label: player.localize('Copy embed code'), 513 },
515 listener: () => { 514 {
516 copyToClipboard(buildVideoOrPlaylistEmbed(videoEmbedUrl, videoEmbedTitle)) 515 label: player.localize('Copy the video URL at the current time'),
516 listener: function (this: videojs.Player) {
517 copyToClipboard(buildVideoLink({ startTime: this.currentTime() }))
518 }
519 },
520 {
521 label: player.localize('Copy embed code'),
522 listener: () => {
523 copyToClipboard(buildVideoOrPlaylistEmbed(videoEmbedUrl, videoEmbedTitle))
524 }
517 } 525 }
526 ]
527
528 if (mode === 'webtorrent') {
529 items.push({
530 label: player.localize('Copy magnet URI'),
531 listener: function (this: videojs.Player) {
532 copyToClipboard(this.webtorrent().getCurrentVideoFile().magnetUri)
533 }
534 })
518 } 535 }
519 ]
520 536
521 if (mode === 'webtorrent') { 537 return items
522 content.push({
523 label: player.localize('Copy magnet URI'),
524 listener: function (this: videojs.Player) {
525 copyToClipboard(this.webtorrent().getCurrentVideoFile().magnetUri)
526 }
527 })
528 } 538 }
529 539
540 // adding the menu
530 player.contextmenuUI({ content }) 541 player.contextmenuUI({ content })
531 } 542 }
532 543