]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/assets/player/peertube-player.ts
Hide big play button on autoplay
[github/Chocobozzz/PeerTube.git] / client / src / assets / player / peertube-player.ts
1 import { VideoFile } from '../../../../shared/models/videos'
2
3 import 'videojs-hotkeys'
4 import 'videojs-dock/dist/videojs-dock.es.js'
5 import './peertube-link-button'
6 import './resolution-menu-button'
7 import './settings-menu-button'
8 import './webtorrent-info-button'
9 import './peertube-videojs-plugin'
10 import { videojsUntyped } from './peertube-videojs-typings'
11
12 // Change 'Playback Rate' to 'Speed' (smaller for our settings menu)
13 videojsUntyped.getComponent('PlaybackRateMenuButton').prototype.controlText_ = 'Speed'
14
15 function getVideojsOptions (options: {
16 autoplay: boolean,
17 playerElement: HTMLVideoElement,
18 videoViewUrl: string,
19 videoDuration: number,
20 videoFiles: VideoFile[],
21 enableHotkeys: boolean,
22 inactivityTimeout: number,
23 peertubeLink: boolean,
24 poster: string,
25 startTime: number
26 }) {
27 const videojsOptions = {
28 controls: true,
29 poster: options.poster,
30 autoplay: options.autoplay,
31 inactivityTimeout: options.inactivityTimeout,
32 playbackRates: [ 0.5, 1, 1.5, 2 ],
33 plugins: {
34 peertube: {
35 videoFiles: options.videoFiles,
36 playerElement: options.playerElement,
37 videoViewUrl: options.videoViewUrl,
38 videoDuration: options.videoDuration,
39 startTime: options.startTime
40 }
41 },
42 controlBar: {
43 children: getControlBarChildren(options)
44 }
45 }
46
47 if (options.enableHotkeys === true) {
48 Object.assign(videojsOptions.plugins, {
49 hotkeys: {
50 enableVolumeScroll: false
51 }
52 })
53 }
54
55 return videojsOptions
56 }
57
58 function getControlBarChildren (options: {
59 peertubeLink: boolean
60 }) {
61 const children = {
62 'playToggle': {},
63 'currentTimeDisplay': {},
64 'timeDivider': {},
65 'durationDisplay': {},
66 'liveDisplay': {},
67
68 'flexibleWidthSpacer': {},
69 'progressControl': {},
70
71 'webTorrentButton': {},
72
73 'muteToggle': {},
74 'volumeControl': {},
75
76 'settingsButton': {
77 setup: {
78 maxHeightOffset: 40
79 },
80 entries: [
81 'resolutionMenuButton',
82 'playbackRateMenuButton'
83 ]
84 }
85 }
86
87 if (options.peertubeLink === true) {
88 Object.assign(children, {
89 'peerTubeLinkButton': {}
90 })
91 }
92
93 Object.assign(children, {
94 'fullscreenToggle': {}
95 })
96
97 return children
98 }
99
100 export { getVideojsOptions }