aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/shared/dock
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-03-14 14:28:20 +0100
committerChocobozzz <me@florianbigard.com>2022-03-14 14:36:35 +0100
commit57d6503286b114fee61b5e4725825e2490dcac29 (patch)
tree2d3d23f697b2986d7e41bb443754394296b66ec3 /client/src/assets/player/shared/dock
parent9597920ee3d4ac99803e7107983ddf98a9dfb3c4 (diff)
downloadPeerTube-57d6503286b114fee61b5e4725825e2490dcac29.tar.gz
PeerTube-57d6503286b114fee61b5e4725825e2490dcac29.tar.zst
PeerTube-57d6503286b114fee61b5e4725825e2490dcac29.zip
Reorganize player files
Diffstat (limited to 'client/src/assets/player/shared/dock')
-rw-r--r--client/src/assets/player/shared/dock/index.ts2
-rw-r--r--client/src/assets/player/shared/dock/peertube-dock-component.ts65
-rw-r--r--client/src/assets/player/shared/dock/peertube-dock-plugin.ts25
3 files changed, 92 insertions, 0 deletions
diff --git a/client/src/assets/player/shared/dock/index.ts b/client/src/assets/player/shared/dock/index.ts
new file mode 100644
index 000000000..16e70a9c1
--- /dev/null
+++ b/client/src/assets/player/shared/dock/index.ts
@@ -0,0 +1,2 @@
1export * from './peertube-dock-component'
2export * from './peertube-dock-plugin'
diff --git a/client/src/assets/player/shared/dock/peertube-dock-component.ts b/client/src/assets/player/shared/dock/peertube-dock-component.ts
new file mode 100644
index 000000000..183c7a00f
--- /dev/null
+++ b/client/src/assets/player/shared/dock/peertube-dock-component.ts
@@ -0,0 +1,65 @@
1import videojs from 'video.js'
2
3const Component = videojs.getComponent('Component')
4
5export type PeerTubeDockComponentOptions = {
6 title?: string
7 description?: string
8 avatarUrl?: string
9}
10
11class PeerTubeDockComponent extends Component {
12
13 createEl () {
14 const options = this.options_ as PeerTubeDockComponentOptions
15
16 const el = super.createEl('div', {
17 className: 'peertube-dock'
18 })
19
20 if (options.avatarUrl) {
21 const avatar = videojs.dom.createEl('img', {
22 className: 'peertube-dock-avatar',
23 src: options.avatarUrl
24 })
25
26 el.appendChild(avatar)
27 }
28
29 const elWrapperTitleDescription = super.createEl('div', {
30 className: 'peertube-dock-title-description'
31 })
32
33 if (options.title) {
34 const title = videojs.dom.createEl('div', {
35 className: 'peertube-dock-title',
36 title: options.title,
37 innerHTML: options.title
38 })
39
40 elWrapperTitleDescription.appendChild(title)
41 }
42
43 if (options.description) {
44 const description = videojs.dom.createEl('div', {
45 className: 'peertube-dock-description',
46 title: options.description,
47 innerHTML: options.description
48 })
49
50 elWrapperTitleDescription.appendChild(description)
51 }
52
53 if (options.title || options.description) {
54 el.appendChild(elWrapperTitleDescription)
55 }
56
57 return el
58 }
59}
60
61videojs.registerComponent('PeerTubeDockComponent', PeerTubeDockComponent)
62
63export {
64 PeerTubeDockComponent
65}
diff --git a/client/src/assets/player/shared/dock/peertube-dock-plugin.ts b/client/src/assets/player/shared/dock/peertube-dock-plugin.ts
new file mode 100644
index 000000000..245981692
--- /dev/null
+++ b/client/src/assets/player/shared/dock/peertube-dock-plugin.ts
@@ -0,0 +1,25 @@
1import videojs from 'video.js'
2import { PeerTubeDockComponent } from './peertube-dock-component'
3
4const Plugin = videojs.getPlugin('plugin')
5
6export type PeerTubeDockPluginOptions = {
7 title?: string
8 description?: string
9 avatarUrl?: string
10}
11
12class PeerTubeDockPlugin extends Plugin {
13 constructor (player: videojs.Player, options: videojs.PlayerOptions & PeerTubeDockPluginOptions) {
14 super(player, options)
15
16 this.player.addClass('peertube-dock')
17
18 this.player.ready(() => {
19 this.player.addChild('PeerTubeDockComponent', options) as PeerTubeDockComponent
20 })
21 }
22}
23
24videojs.registerPlugin('peertubeDock', PeerTubeDockPlugin)
25export { PeerTubeDockPlugin }