]>
Commit | Line | Data |
---|---|---|
c6352f2c C |
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, | |
33d78552 C |
23 | peertubeLink: boolean, |
24 | poster: string | |
c6352f2c C |
25 | }) { |
26 | const videojsOptions = { | |
27 | controls: true, | |
33d78552 | 28 | poster: options.poster, |
c6352f2c C |
29 | autoplay: options.autoplay, |
30 | inactivityTimeout: options.inactivityTimeout, | |
31 | playbackRates: [ 0.5, 1, 1.5, 2 ], | |
32 | plugins: { | |
33 | peertube: { | |
34 | videoFiles: options.videoFiles, | |
35 | playerElement: options.playerElement, | |
36 | videoViewUrl: options.videoViewUrl, | |
37 | videoDuration: options.videoDuration | |
38 | } | |
39 | }, | |
40 | controlBar: { | |
41 | children: getControlBarChildren(options) | |
42 | } | |
43 | } | |
44 | ||
45 | if (options.enableHotkeys === true) { | |
46 | Object.assign(videojsOptions.plugins, { | |
47 | hotkeys: { | |
48 | enableVolumeScroll: false | |
49 | } | |
50 | }) | |
51 | } | |
52 | ||
53 | return videojsOptions | |
54 | } | |
55 | ||
56 | function getControlBarChildren (options: { | |
57 | peertubeLink: boolean | |
58 | }) { | |
59 | const children = { | |
60 | 'playToggle': {}, | |
61 | 'currentTimeDisplay': {}, | |
62 | 'timeDivider': {}, | |
63 | 'durationDisplay': {}, | |
64 | 'liveDisplay': {}, | |
65 | ||
66 | 'flexibleWidthSpacer': {}, | |
67 | 'progressControl': {}, | |
68 | ||
69 | 'webTorrentButton': {}, | |
70 | ||
71 | 'muteToggle': {}, | |
72 | 'volumeControl': {}, | |
73 | ||
74 | 'settingsButton': { | |
75 | setup: { | |
76 | maxHeightOffset: 40 | |
77 | }, | |
78 | entries: [ | |
79 | 'resolutionMenuButton', | |
80 | 'playbackRateMenuButton' | |
81 | ] | |
82 | } | |
83 | } | |
84 | ||
85 | if (options.peertubeLink === true) { | |
86 | Object.assign(children, { | |
87 | 'peerTubeLinkButton': {} | |
88 | }) | |
89 | } | |
90 | ||
91 | Object.assign(children, { | |
92 | 'fullscreenToggle': {} | |
93 | }) | |
94 | ||
95 | return children | |
96 | } | |
97 | ||
98 | export { getVideojsOptions } |