]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Revert "Fix context menu when watching a playlist"
authorChocobozzz <me@florianbigard.com>
Wed, 21 Apr 2021 13:28:12 +0000 (15:28 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 21 Apr 2021 13:28:12 +0000 (15:28 +0200)
This reverts commit e8bb5b6b3a1e4c2aeab368f01cc5092d8478b893.

We'll refactor this error handler in hls.js v1 upgrade

client/src/app/+videos/+video-watch/video-watch.component.ts
client/src/assets/player/peertube-player-manager.ts
client/src/assets/player/peertube-videojs-typings.ts
client/src/assets/player/utils.ts
client/src/standalone/videos/embed.ts
scripts/i18n/create-custom-files.ts

index 2216bdd4a194072b0b2d35ff21ba4c01cbfa4577..366e9bb57ce5bb809b3a0332d2b610f651464d4f 100644 (file)
@@ -795,19 +795,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
       src: environment.apiUrl + c.captionPath
     }))
 
-    const playlistOptions = this.playlist
-      ? {
-        createComponent: false,
-
-        playlist: this.playlist,
-
-        getCurrentPosition: () => this.playlistPosition,
-
-        embedUrl: this.playlist.embedUrl,
-        embedTitle: this.playlist.displayName
-      }
-      : undefined
-
     const options: PeertubePlayerManagerOptions = {
       common: {
         autoplay: this.isAutoplay(),
@@ -852,9 +839,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
 
         videoCaptions: playerCaptions,
 
-        videoUUID: video.uuid,
-
-        playlist: playlistOptions
+        videoUUID: video.uuid
       },
 
       webtorrent: {
index 689e70fb5751d8ac638cb90dc3f4888474c9054d..ed82e0496595611024ac9fe0703d0aa5bd4bc0bd 100644 (file)
@@ -35,7 +35,7 @@ import {
   VideoJSPluginOptions
 } from './peertube-videojs-typings'
 import { TranslationsManager } from './translations-manager'
-import { buildVideoOrPlaylistEmbed, buildVideoLink, getRtcConfig, isSafari, isIOS, buildPlaylistLink } from './utils'
+import { buildVideoOrPlaylistEmbed, buildVideoLink, getRtcConfig, isSafari, isIOS } from './utils'
 import { copyToClipboard } from '../../root-helpers/utils'
 
 // Change 'Playback Rate' to 'Speed' (smaller for our settings menu)
@@ -87,8 +87,6 @@ export interface CommonOptions extends CustomizationOptions {
   hasPreviousVideo?: () => boolean
 
   playlist?: PlaylistPluginOptions
-  playlistEmbedUrl?: string
-  playlistEmbedTitle?: string
 
   videoDuration: number
   enableHotkeys: boolean
@@ -169,13 +167,7 @@ export class PeertubePlayerManager {
           PeertubePlayerManager.alreadyPlayed = true
         })
 
-        self.addContextMenu({
-          mode,
-          player,
-          videoEmbedUrl: options.common.embedUrl,
-          videoEmbedTitle: options.common.embedTitle,
-          playlist: options.common.playlist
-        })
+        self.addContextMenu(mode, player, options.common.embedUrl, options.common.embedTitle)
 
         player.bezels()
 
@@ -213,13 +205,7 @@ export class PeertubePlayerManager {
     videojs(newVideoElement, videojsOptions, function (this: videojs.Player) {
       const player = this
 
-      self.addContextMenu({
-        mode,
-        player,
-        videoEmbedUrl: options.common.embedUrl,
-        videoEmbedTitle: options.common.embedTitle,
-        playlist: options.common.playlist
-      })
+      self.addContextMenu(mode, player, options.common.embedUrl, options.common.embedTitle)
 
       PeertubePlayerManager.onPlayerChange(player)
     })
@@ -253,7 +239,7 @@ export class PeertubePlayerManager {
       }
     }
 
-    if (commonOptions.playlist?.createComponent === true) {
+    if (commonOptions.playlist) {
       plugins.playlist = commonOptions.playlist
     }
 
@@ -511,71 +497,37 @@ export class PeertubePlayerManager {
     return children
   }
 
-  private static addContextMenu (options: {
-    mode: PlayerMode
-    player: videojs.Player
-    videoEmbedUrl: string
-    videoEmbedTitle: string
-    playlist?: PlaylistPluginOptions
-  }) {
-    const { mode, player, videoEmbedUrl, videoEmbedTitle, playlist } = options
-
+  private static addContextMenu (mode: PlayerMode, player: videojs.Player, videoEmbedUrl: string, videoEmbedTitle: string) {
     const content = () => {
-      let items: { icon?: string, label: string, listener: Function }[] = []
-
-      if (!playlist) {
-        const isLoopEnabled = player.options_['loop']
-        items = items.concat([
-          {
-            icon: 'repeat',
-            label: player.localize('Play in loop') + (isLoopEnabled ? '<span class="vjs-icon-tick-white"></span>' : ''),
-            listener: function () {
-              player.options_['loop'] = !isLoopEnabled
-            }
-          },
-          {
-            label: player.localize('Copy the video URL'),
-            listener: function () {
-              copyToClipboard(buildVideoLink())
-            }
-          },
-          {
-            label: player.localize('Copy the video URL at the current time'),
-            listener: function (this: videojs.Player) {
-              copyToClipboard(buildVideoLink({ startTime: this.currentTime() }))
-            }
+      const isLoopEnabled = player.options_['loop']
+      const items = [
+        {
+          icon: 'repeat',
+          label: player.localize('Play in loop') + (isLoopEnabled ? '<span class="vjs-icon-tick-white"></span>' : ''),
+          listener: function () {
+            player.options_['loop'] = !isLoopEnabled
           }
-        ])
-      } else {
-        items = items.concat([
-          {
-            label: player.localize('Copy the playlist URL'),
-            listener: function () {
-              copyToClipboard(buildPlaylistLink())
-            }
-          },
-          {
-            label: player.localize('Copy the playlist URL at current video position'),
-            listener: function (this: videojs.Player) {
-              copyToClipboard(buildPlaylistLink({ playlistPosition: playlist.getCurrentPosition() }))
-            }
-          },
-          {
-            label: player.localize('Copy the playlist embed code'),
-            listener: function (this: videojs.Player) {
-              copyToClipboard(buildVideoOrPlaylistEmbed(playlist.embedUrl, playlist.embedTitle))
-            }
+        },
+        {
+          label: player.localize('Copy the video URL'),
+          listener: function () {
+            copyToClipboard(buildVideoLink())
+          }
+        },
+        {
+          label: player.localize('Copy the video URL at the current time'),
+          listener: function (this: videojs.Player) {
+            copyToClipboard(buildVideoLink({ startTime: this.currentTime() }))
+          }
+        },
+        {
+          icon: 'code',
+          label: player.localize('Copy embed code'),
+          listener: () => {
+            copyToClipboard(buildVideoOrPlaylistEmbed(videoEmbedUrl, videoEmbedTitle))
           }
-        ])
-      }
-
-      items = items.concat({
-        icon: 'code',
-        label: player.localize('Copy video embed code'),
-        listener: () => {
-          copyToClipboard(buildVideoOrPlaylistEmbed(videoEmbedUrl, videoEmbedTitle))
         }
-      })
+      ]
 
       if (mode === 'webtorrent') {
         items.push({
index a48ff2cd0c9108c0e7665027338c829386165991..4a6c8024767cd20f15c45a1e941ba60315879fcf 100644 (file)
@@ -113,18 +113,13 @@ type PeerTubePluginOptions = {
 }
 
 type PlaylistPluginOptions = {
-  createComponent: boolean
-
-  elements?: VideoPlaylistElement[]
+  elements: VideoPlaylistElement[]
 
   playlist: VideoPlaylist
 
   getCurrentPosition: () => number
 
-  embedUrl: string
-  embedTitle: string
-
-  onItemClicked?: (element: VideoPlaylistElement) => void
+  onItemClicked: (element: VideoPlaylistElement) => void
 }
 
 type NextPreviousVideoButtonOptions = {
index 136b69b4fc5afc23fc26bddc1c15769a5c800f3e..d7451fa1d1fcf3f3c1037f28cb5cf6fdd6140003 100644 (file)
@@ -94,8 +94,9 @@ function buildVideoLink (options: {
 
 function buildPlaylistLink (options: {
   baseUrl?: string
-  playlistPosition?: number
-} = {}) {
+
+  playlistPosition: number
+}) {
   const { baseUrl } = options
 
   const url = baseUrl
@@ -105,7 +106,6 @@ function buildPlaylistLink (options: {
   const params = generateParams(window.location.search)
 
   if (options.playlistPosition) params.set('playlistPosition', '' + options.playlistPosition)
-  else params.delete('playlistPosition')
 
   return buildUrl(url, params)
 }
index 9e5b2a655ecae253d39cd074f0565cf777dda302..103014bb08dd3c7c23bd58c6a88e79da405fc2c0 100644 (file)
@@ -492,8 +492,6 @@ export class PeerTubeEmbed {
 
     const playlistPlugin = this.currentPlaylistElement
       ? {
-        createComponent: true,
-
         elements: this.playlistElements,
         playlist: this.playlist,
 
@@ -504,10 +502,7 @@ export class PeerTubeEmbed {
 
           this.loadVideoAndBuildPlayer(this.currentPlaylistElement.video.uuid)
             .catch(err => console.error(err))
-        },
-
-        embedTitle: this.playlist.displayName,
-        embedUrl: window.location.origin + this.playlist.embedPath
+        }
       }
       : undefined
 
index 111bcbf4c816a10a19293d8f1b7909da67d11f3e..d4d5b44f05a00030bb89e6a56a73e0f8c8e25c25 100755 (executable)
@@ -29,18 +29,14 @@ const playerKeys = {
   'Watching this video may reveal your IP address to others.': 'Watching this video may reveal your IP address to others.',
   'Copy the video URL': 'Copy the video URL',
   'Copy the video URL at the current time': 'Copy the video URL at the current time',
-  'Copy video embed code': 'Copy video embed code',
+  'Copy embed code': 'Copy embed code',
   'Copy magnet URI': 'Copy magnet URI',
   'Total downloaded: ': 'Total downloaded: ',
   'Total uploaded: ': 'Total uploaded: ',
   'From servers: ': 'From servers: ',
   'From peers: ': 'From peers: ',
   'Normal mode': 'Normal mode',
-  'Play in loop': 'Play in loop',
-  'Theater mode': 'Theater mode',
-  'Copy the playlist URL': 'Copy the playlist URL',
-  'Copy the playlist URL at current video position': 'Copy the playlist URL at current video position',
-  'Copy the playlist embed code': 'Copy the playlist embed code'
+  'Theater mode': 'Theater mode'
 }
 Object.assign(playerKeys, videojs)