1 import { VideoFile } from '../../../../shared/models/videos'
3 import 'videojs-hotkeys'
5 import 'videojs-contextmenu'
6 import 'videojs-contextmenu-ui'
7 import './peertube-link-button'
8 import './resolution-menu-button'
9 import './settings-menu-button'
10 import './webtorrent-info-button'
11 import './peertube-videojs-plugin'
12 import { videojsUntyped } from './peertube-videojs-typings'
13 import { buildVideoEmbed, buildVideoLink, copyToClipboard } from './utils'
15 // Change 'Playback Rate' to 'Speed' (smaller for our settings menu)
16 videojsUntyped.getComponent('PlaybackRateMenuButton').prototype.controlText_ = 'Speed'
18 function getVideojsOptions (options: {
20 playerElement: HTMLVideoElement,
22 videoEmbedUrl: string,
23 videoDuration: number,
24 videoFiles: VideoFile[],
25 enableHotkeys: boolean,
26 inactivityTimeout: number,
27 peertubeLink: boolean,
31 const videojsOptions = {
33 poster: options.poster,
35 inactivityTimeout: options.inactivityTimeout,
36 playbackRates: [ 0.5, 1, 1.5, 2 ],
39 autoplay: options.autoplay, // Use peertube plugin autoplay because we get the file by webtorrent
40 videoFiles: options.videoFiles,
41 playerElement: options.playerElement,
42 videoViewUrl: options.videoViewUrl,
43 videoDuration: options.videoDuration,
44 startTime: options.startTime
49 label: 'Copy the video URL',
50 listener: function () {
51 copyToClipboard(buildVideoLink())
55 label: 'Copy the video URL at the current time',
56 listener: function () {
58 copyToClipboard(buildVideoLink(player.currentTime()))
62 label: 'Copy embed code',
64 copyToClipboard(buildVideoEmbed(options.videoEmbedUrl))
71 children: getControlBarChildren(options)
75 if (options.enableHotkeys === true) {
76 Object.assign(videojsOptions.plugins, {
78 enableVolumeScroll: false
86 function getControlBarChildren (options: {
91 'currentTimeDisplay': {},
93 'durationDisplay': {},
96 'flexibleWidthSpacer': {},
97 'progressControl': {},
99 'webTorrentButton': {},
109 'resolutionMenuButton',
110 'playbackRateMenuButton'
115 if (options.peertubeLink === true) {
116 Object.assign(children, {
117 'peerTubeLinkButton': {}
121 Object.assign(children, {
122 'fullscreenToggle': {}
128 export { getVideojsOptions }