]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/assets/player/peertube-player.ts
Upgrade client dependencies
[github/Chocobozzz/PeerTube.git] / client / src / assets / player / peertube-player.ts
CommitLineData
c6352f2c
C
1import { VideoFile } from '../../../../shared/models/videos'
2
cd4d7a2c
C
3import 'core-js/es6/symbol';
4import 'core-js/es6/object';
5import 'core-js/es6/function';
6import 'core-js/es6/parse-int';
7import 'core-js/es6/parse-float';
8import 'core-js/es6/number';
9import 'core-js/es6/math';
10import 'core-js/es6/string';
11import 'core-js/es6/date';
12import 'core-js/es6/array';
13import 'core-js/es6/regexp';
14import 'core-js/es6/map';
15import 'core-js/es6/weak-map';
16import 'core-js/es6/set';
17import 'core-js/es7/object';
18
c6352f2c 19import 'videojs-hotkeys'
c7b0dacb 20import 'videojs-dock'
c6352f2c
C
21import './peertube-link-button'
22import './resolution-menu-button'
23import './settings-menu-button'
24import './webtorrent-info-button'
25import './peertube-videojs-plugin'
26import { videojsUntyped } from './peertube-videojs-typings'
27
28// Change 'Playback Rate' to 'Speed' (smaller for our settings menu)
29videojsUntyped.getComponent('PlaybackRateMenuButton').prototype.controlText_ = 'Speed'
30
31function getVideojsOptions (options: {
32 autoplay: boolean,
33 playerElement: HTMLVideoElement,
34 videoViewUrl: string,
35 videoDuration: number,
36 videoFiles: VideoFile[],
37 enableHotkeys: boolean,
38 inactivityTimeout: number,
33d78552 39 peertubeLink: boolean,
f37bad63
C
40 poster: string,
41 startTime: number
c6352f2c
C
42}) {
43 const videojsOptions = {
44 controls: true,
33d78552 45 poster: options.poster,
80109b2d 46 autoplay: false,
c6352f2c
C
47 inactivityTimeout: options.inactivityTimeout,
48 playbackRates: [ 0.5, 1, 1.5, 2 ],
49 plugins: {
50 peertube: {
80109b2d 51 autoplay: options.autoplay, // Use peertube plugin autoplay because we get the file by webtorrent
c6352f2c
C
52 videoFiles: options.videoFiles,
53 playerElement: options.playerElement,
54 videoViewUrl: options.videoViewUrl,
f37bad63
C
55 videoDuration: options.videoDuration,
56 startTime: options.startTime
c6352f2c
C
57 }
58 },
59 controlBar: {
60 children: getControlBarChildren(options)
61 }
62 }
63
64 if (options.enableHotkeys === true) {
65 Object.assign(videojsOptions.plugins, {
66 hotkeys: {
67 enableVolumeScroll: false
68 }
69 })
70 }
71
72 return videojsOptions
73}
74
75function getControlBarChildren (options: {
76 peertubeLink: boolean
77}) {
78 const children = {
79 'playToggle': {},
80 'currentTimeDisplay': {},
81 'timeDivider': {},
82 'durationDisplay': {},
83 'liveDisplay': {},
84
85 'flexibleWidthSpacer': {},
86 'progressControl': {},
87
88 'webTorrentButton': {},
89
90 'muteToggle': {},
91 'volumeControl': {},
92
93 'settingsButton': {
94 setup: {
95 maxHeightOffset: 40
96 },
97 entries: [
98 'resolutionMenuButton',
99 'playbackRateMenuButton'
100 ]
101 }
102 }
103
104 if (options.peertubeLink === true) {
105 Object.assign(children, {
106 'peerTubeLinkButton': {}
107 })
108 }
109
110 Object.assign(children, {
111 'fullscreenToggle': {}
112 })
113
114 return children
115}
116
117export { getVideojsOptions }