import 'videojs-hotkeys/videojs.hotkeys'
import 'videojs-dock'
-import 'videojs-contextmenu-ui'
+import 'videojs-contextmenu-pt'
import 'videojs-contrib-quality-levels'
import './upnext/end-card'
import './upnext/upnext-plugin'
videoViewUrl: string
embedUrl: string
+ embedTitle: string
isLive: boolean
videoCaptions: VideoJSCaption[]
+ videoUUID: string
+
userWatching?: UserWatching
serverUrl: string
export class PeertubePlayerManager {
private static playerElementClassName: string
private static onPlayerChange: (player: videojs.Player) => void
-
private static alreadyPlayed = false
static initState () {
PeertubePlayerManager.alreadyPlayed = true
})
- self.addContextMenu(mode, player, options.common.embedUrl)
+ self.addContextMenu(mode, player, options.common.embedUrl, options.common.embedTitle)
player.bezels()
videojs(newVideoElement, videojsOptions, function (this: videojs.Player) {
const player = this
- self.addContextMenu(mode, player, options.common.embedUrl)
+ self.addContextMenu(mode, player, options.common.embedUrl, options.common.embedTitle)
PeertubePlayerManager.onPlayerChange(player)
})
subtitle: commonOptions.subtitle,
videoCaptions: commonOptions.videoCaptions,
stopTime: commonOptions.stopTime,
- isLive: commonOptions.isLive
+ isLive: commonOptions.isLive,
+ videoUUID: commonOptions.videoUUID
}
}
return children
}
- private static addContextMenu (mode: PlayerMode, player: videojs.Player, videoEmbedUrl: string) {
- const content = [
- {
- 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() }))
- }
- },
- {
- label: player.localize('Copy embed code'),
- listener: () => {
- copyToClipboard(buildVideoOrPlaylistEmbed(videoEmbedUrl))
+ private static addContextMenu (mode: PlayerMode, player: videojs.Player, videoEmbedUrl: string, videoEmbedTitle: string) {
+ const content = () => {
+ const isLoopEnabled = player.options_['loop']
+ const items = [
+ {
+ label: isLoopEnabled ? player.localize('Stop playing in loop') : player.localize('Play in loop'),
+ 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() }))
+ }
+ },
+ {
+ label: player.localize('Copy embed code'),
+ listener: () => {
+ copyToClipboard(buildVideoOrPlaylistEmbed(videoEmbedUrl, videoEmbedTitle))
+ }
}
+ ]
+
+ if (mode === 'webtorrent') {
+ items.push({
+ label: player.localize('Copy magnet URI'),
+ listener: function (this: videojs.Player) {
+ copyToClipboard(this.webtorrent().getCurrentVideoFile().magnetUri)
+ }
+ })
}
- ]
- if (mode === 'webtorrent') {
- content.push({
- label: player.localize('Copy magnet URI'),
- listener: function (this: videojs.Player) {
- copyToClipboard(this.webtorrent().getCurrentVideoFile().magnetUri)
- }
- })
+ return items
}
+ // adding the menu
player.contextmenuUI({ content })
}