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 './peertube-load-progress-bar'
13 import { videojsUntyped } from './peertube-videojs-typings'
14 import { buildVideoEmbed, buildVideoLink, copyToClipboard } from './utils'
16 // Change 'Playback Rate' to 'Speed' (smaller for our settings menu)
17 videojsUntyped.getComponent('PlaybackRateMenuButton').prototype.controlText_ = 'Speed'
19 function getVideojsOptions (options: {
21 playerElement: HTMLVideoElement,
23 videoEmbedUrl: string,
24 videoDuration: number,
25 videoFiles: VideoFile[],
26 enableHotkeys: boolean,
27 inactivityTimeout: number,
28 peertubeLink: boolean,
32 const videojsOptions = {
34 poster: options.poster,
36 inactivityTimeout: options.inactivityTimeout,
37 playbackRates: [ 0.5, 1, 1.5, 2 ],
40 autoplay: options.autoplay, // Use peertube plugin autoplay because we get the file by webtorrent
41 videoFiles: options.videoFiles,
42 playerElement: options.playerElement,
43 videoViewUrl: options.videoViewUrl,
44 videoDuration: options.videoDuration,
45 startTime: options.startTime
50 label: 'Copy the video URL',
51 listener: function () {
52 copyToClipboard(buildVideoLink())
56 label: 'Copy the video URL at the current time',
57 listener: function () {
59 copyToClipboard(buildVideoLink(player.currentTime()))
63 label: 'Copy embed code',
65 copyToClipboard(buildVideoEmbed(options.videoEmbedUrl))
72 children: getControlBarChildren(options)
76 if (options.enableHotkeys === true) {
77 Object.assign(videojsOptions.plugins, {
79 enableVolumeScroll: false
87 function getControlBarChildren (options: {
92 'currentTimeDisplay': {},
94 'durationDisplay': {},
97 'flexibleWidthSpacer': {},
102 'peerTubeLoadProgressBar': {},
103 'playProgressBar': {}
109 'webTorrentButton': {},
119 'resolutionMenuButton',
120 'playbackRateMenuButton'
125 if (options.peertubeLink === true) {
126 Object.assign(children, {
127 'peerTubeLinkButton': {}
131 Object.assign(children, {
132 'fullscreenToggle': {}
138 export { getVideojsOptions }