]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/assets/player/p2p-media-loader-plugin.ts
Refractor videojs player
[github/Chocobozzz/PeerTube.git] / client / src / assets / player / p2p-media-loader-plugin.ts
1 // FIXME: something weird with our path definition in tsconfig and typings
2 // @ts-ignore
3 import * as videojs from 'video.js'
4 import { P2PMediaLoaderPluginOptions, VideoJSComponentInterface } from './peertube-videojs-typings'
5
6 // videojs-hlsjs-plugin needs videojs in window
7 window['videojs'] = videojs
8 import '@streamroot/videojs-hlsjs-plugin'
9
10 import { initVideoJsContribHlsJsPlayer } from 'p2p-media-loader-hlsjs'
11
12 // import { Events } from '../p2p-media-loader/p2p-media-loader-core/lib'
13
14 const Plugin: VideoJSComponentInterface = videojs.getPlugin('plugin')
15 class P2pMediaLoaderPlugin extends Plugin {
16
17 constructor (player: videojs.Player, options: P2PMediaLoaderPluginOptions) {
18 super(player, options)
19
20 initVideoJsContribHlsJsPlayer(player)
21
22 console.log(options)
23
24 player.src({
25 type: options.type,
26 src: options.src
27 })
28 }
29
30 }
31
32 videojs.registerPlugin('p2pMediaLoader', P2pMediaLoaderPlugin)
33 export { P2pMediaLoaderPlugin }