From 2adfc7ea9a1f858db874df9fe322e7ae833db77c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 23 Jan 2019 15:36:45 +0100 Subject: Refractor videojs player Add fake p2p-media-loader plugin --- .../videojs-components/peertube-link-button.ts | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 client/src/assets/player/videojs-components/peertube-link-button.ts (limited to 'client/src/assets/player/videojs-components/peertube-link-button.ts') 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 @@ +import { VideoJSComponentInterface, videojsUntyped } from '../peertube-videojs-typings' +import { buildVideoLink } from '../utils' +// FIXME: something weird with our path definition in tsconfig and typings +// @ts-ignore +import { Player } from 'video.js' + +const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button') +class PeerTubeLinkButton extends Button { + + constructor (player: Player, options: any) { + super(player, options) + } + + createEl () { + return this.buildElement() + } + + updateHref () { + this.el().setAttribute('href', buildVideoLink(this.player().currentTime())) + } + + handleClick () { + this.player_.pause() + } + + private buildElement () { + const el = videojsUntyped.dom.createEl('a', { + href: buildVideoLink(), + innerHTML: 'PeerTube', + title: this.player_.localize('Go to the video page'), + className: 'vjs-peertube-link', + target: '_blank' + }) + + el.addEventListener('mouseenter', () => this.updateHref()) + + return el + } +} +Button.registerComponent('PeerTubeLinkButton', PeerTubeLinkButton) -- cgit v1.2.3