VideoJSPluginOptions
} from './peertube-videojs-typings'
import { TranslationsManager } from './translations-manager'
-import { buildVideoOrPlaylistEmbed, buildVideoLink, copyToClipboard, getRtcConfig, isSafari, isIOS } 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)
(videojs.getComponent('PlaybackRateMenuButton') as any).prototype.controlText_ = 'Speed'
videoViewUrl: string
embedUrl: string
+ embedTitle: string
isLive: boolean
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)
})
const plugins: VideoJSPluginOptions = {
peertube: {
mode,
- autoplay, // Use peertube plugin autoplay because we get the file by webtorrent
+ autoplay, // Use peertube plugin autoplay because we could get the file by webtorrent
videoViewUrl: commonOptions.videoViewUrl,
videoDuration: commonOptions.videoDuration,
userWatching: commonOptions.userWatching,
subtitle: commonOptions.subtitle,
videoCaptions: commonOptions.videoCaptions,
- stopTime: commonOptions.stopTime
+ stopTime: commonOptions.stopTime,
+ isLive: commonOptions.isLive
}
}
poster: commonOptions.poster,
inactivityTimeout: commonOptions.inactivityTimeout,
- playbackRates: [ 0.5, 0.75, 1, 1.25, 1.5, 2 ],
+ playbackRates: [ 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2 ],
plugins,
return children
}
- private static addContextMenu (mode: PlayerMode, player: videojs.Player, videoEmbedUrl: string) {
+ private static addContextMenu (mode: PlayerMode, player: videojs.Player, videoEmbedUrl: string, videoEmbedTitle: string) {
const content = [
{
label: player.localize('Copy the video URL'),
{
label: player.localize('Copy embed code'),
listener: () => {
- copyToClipboard(buildVideoOrPlaylistEmbed(videoEmbedUrl))
+ copyToClipboard(buildVideoOrPlaylistEmbed(videoEmbedUrl, videoEmbedTitle))
}
}
]
}
private static addHotkeysOptions (plugins: VideoJSPluginOptions) {
+ const isNaked = (event: KeyboardEvent, key: string) =>
+ (!event.ctrlKey && !event.altKey && !event.metaKey && !event.shiftKey && event.key === key)
+
Object.assign(plugins, {
hotkeys: {
skipInitialFocus: true,
enableVolumeScroll: false,
enableModifiersForNumbers: false,
- fullscreenKey: function (event: KeyboardEvent) {
- // fullscreen with the f key or Ctrl+Enter
- return event.key === 'f' || (event.ctrlKey && event.key === 'Enter')
+ rewindKey: function (event: KeyboardEvent) {
+ return isNaked(event, 'ArrowLeft')
},
- seekStep: function (event: KeyboardEvent) {
- // mimic VLC seek behavior, and default to 5 (original value is 5).
- if (event.ctrlKey && event.altKey) {
- return 5 * 60
- } else if (event.ctrlKey) {
- return 60
- } else if (event.altKey) {
- return 10
- } else {
- return 5
- }
+ forwardKey: function (event: KeyboardEvent) {
+ return isNaked(event, 'ArrowRight')
+ },
+
+ fullscreenKey: function (event: KeyboardEvent) {
+ // fullscreen with the f key or Ctrl+Enter
+ return isNaked(event, 'f') || (!event.altKey && event.ctrlKey && event.key === 'Enter')
},
customKeys: {
increasePlaybackRateKey: {
key: function (event: KeyboardEvent) {
- return event.key === '>'
+ return isNaked(event, '>')
},
handler: function (player: videojs.Player) {
const newValue = Math.min(player.playbackRate() + 0.1, 5)
},
decreasePlaybackRateKey: {
key: function (event: KeyboardEvent) {
- return event.key === '<'
+ return isNaked(event, '<')
},
handler: function (player: videojs.Player) {
const newValue = Math.max(player.playbackRate() - 0.1, 0.10)
},
frameByFrame: {
key: function (event: KeyboardEvent) {
- return event.key === '.'
+ return isNaked(event, '.')
},
handler: function (player: videojs.Player) {
player.pause()