aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/peertube-player.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-03-30 17:40:00 +0200
committerChocobozzz <me@florianbigard.com>2018-04-03 14:02:10 +0200
commitc6352f2c64f3c1ad54f8500f493587cdce3d33c9 (patch)
tree642a5b29b4d68ed8915e5e800232eab069303f79 /client/src/assets/player/peertube-player.ts
parent6b9af1293621a81564296ead6f12f5e70eafbca2 (diff)
downloadPeerTube-c6352f2c64f3c1ad54f8500f493587cdce3d33c9.tar.gz
PeerTube-c6352f2c64f3c1ad54f8500f493587cdce3d33c9.tar.zst
PeerTube-c6352f2c64f3c1ad54f8500f493587cdce3d33c9.zip
Improve player
Add a settings dialog based on the work of Yanko Shterev (@yshterev): https://github.com/yshterev/videojs-settings-menu. Thanks!
Diffstat (limited to 'client/src/assets/player/peertube-player.ts')
-rw-r--r--client/src/assets/player/peertube-player.ts96
1 files changed, 96 insertions, 0 deletions
diff --git a/client/src/assets/player/peertube-player.ts b/client/src/assets/player/peertube-player.ts
new file mode 100644
index 000000000..4ae3e71bd
--- /dev/null
+++ b/client/src/assets/player/peertube-player.ts
@@ -0,0 +1,96 @@
1import { VideoFile } from '../../../../shared/models/videos'
2
3import 'videojs-hotkeys'
4import 'videojs-dock/dist/videojs-dock.es.js'
5import './peertube-link-button'
6import './resolution-menu-button'
7import './settings-menu-button'
8import './webtorrent-info-button'
9import './peertube-videojs-plugin'
10import { videojsUntyped } from './peertube-videojs-typings'
11
12// Change 'Playback Rate' to 'Speed' (smaller for our settings menu)
13videojsUntyped.getComponent('PlaybackRateMenuButton').prototype.controlText_ = 'Speed'
14
15function 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}) {
25 const videojsOptions = {
26 controls: true,
27 autoplay: options.autoplay,
28 inactivityTimeout: options.inactivityTimeout,
29 playbackRates: [ 0.5, 1, 1.5, 2 ],
30 plugins: {
31 peertube: {
32 videoFiles: options.videoFiles,
33 playerElement: options.playerElement,
34 videoViewUrl: options.videoViewUrl,
35 videoDuration: options.videoDuration
36 }
37 },
38 controlBar: {
39 children: getControlBarChildren(options)
40 }
41 }
42
43 if (options.enableHotkeys === true) {
44 Object.assign(videojsOptions.plugins, {
45 hotkeys: {
46 enableVolumeScroll: false
47 }
48 })
49 }
50
51 return videojsOptions
52}
53
54function getControlBarChildren (options: {
55 peertubeLink: boolean
56}) {
57 const children = {
58 'playToggle': {},
59 'currentTimeDisplay': {},
60 'timeDivider': {},
61 'durationDisplay': {},
62 'liveDisplay': {},
63
64 'flexibleWidthSpacer': {},
65 'progressControl': {},
66
67 'webTorrentButton': {},
68
69 'muteToggle': {},
70 'volumeControl': {},
71
72 'settingsButton': {
73 setup: {
74 maxHeightOffset: 40
75 },
76 entries: [
77 'resolutionMenuButton',
78 'playbackRateMenuButton'
79 ]
80 }
81 }
82
83 if (options.peertubeLink === true) {
84 Object.assign(children, {
85 'peerTubeLinkButton': {}
86 })
87 }
88
89 Object.assign(children, {
90 'fullscreenToggle': {}
91 })
92
93 return children
94}
95
96export { getVideojsOptions }