aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/videojs-components/peertube-link-button.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-01-23 15:36:45 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-02-11 09:13:02 +0100
commit2adfc7ea9a1f858db874df9fe322e7ae833db77c (patch)
treee27c6ebe01b7c96ea0e053839a38fc1f824d1284 /client/src/assets/player/videojs-components/peertube-link-button.ts
parent7eeb6a0ba4028d0e20847b846332dd0b7747c7f8 (diff)
downloadPeerTube-2adfc7ea9a1f858db874df9fe322e7ae833db77c.tar.gz
PeerTube-2adfc7ea9a1f858db874df9fe322e7ae833db77c.tar.zst
PeerTube-2adfc7ea9a1f858db874df9fe322e7ae833db77c.zip
Refractor videojs player
Add fake p2p-media-loader plugin
Diffstat (limited to 'client/src/assets/player/videojs-components/peertube-link-button.ts')
-rw-r--r--client/src/assets/player/videojs-components/peertube-link-button.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/client/src/assets/player/videojs-components/peertube-link-button.ts b/client/src/assets/player/videojs-components/peertube-link-button.ts
new file mode 100644
index 000000000..fed8ea33e
--- /dev/null
+++ b/client/src/assets/player/videojs-components/peertube-link-button.ts
@@ -0,0 +1,40 @@
1import { VideoJSComponentInterface, videojsUntyped } from '../peertube-videojs-typings'
2import { buildVideoLink } from '../utils'
3// FIXME: something weird with our path definition in tsconfig and typings
4// @ts-ignore
5import { Player } from 'video.js'
6
7const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button')
8class PeerTubeLinkButton extends Button {
9
10 constructor (player: Player, options: any) {
11 super(player, options)
12 }
13
14 createEl () {
15 return this.buildElement()
16 }
17
18 updateHref () {
19 this.el().setAttribute('href', buildVideoLink(this.player().currentTime()))
20 }
21
22 handleClick () {
23 this.player_.pause()
24 }
25
26 private buildElement () {
27 const el = videojsUntyped.dom.createEl('a', {
28 href: buildVideoLink(),
29 innerHTML: 'PeerTube',
30 title: this.player_.localize('Go to the video page'),
31 className: 'vjs-peertube-link',
32 target: '_blank'
33 })
34
35 el.addEventListener('mouseenter', () => this.updateHref())
36
37 return el
38 }
39}
40Button.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton)