aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/p2p-media-loader-plugin.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/p2p-media-loader-plugin.ts')
-rw-r--r--client/src/assets/player/p2p-media-loader-plugin.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/client/src/assets/player/p2p-media-loader-plugin.ts b/client/src/assets/player/p2p-media-loader-plugin.ts
new file mode 100644
index 000000000..6d07a2c9c
--- /dev/null
+++ b/client/src/assets/player/p2p-media-loader-plugin.ts
@@ -0,0 +1,33 @@
1// FIXME: something weird with our path definition in tsconfig and typings
2// @ts-ignore
3import * as videojs from 'video.js'
4import { P2PMediaLoaderPluginOptions, VideoJSComponentInterface } from './peertube-videojs-typings'
5
6// videojs-hlsjs-plugin needs videojs in window
7window['videojs'] = videojs
8import '@streamroot/videojs-hlsjs-plugin'
9
10import { initVideoJsContribHlsJsPlayer } from 'p2p-media-loader-hlsjs'
11
12// import { Events } from '../p2p-media-loader/p2p-media-loader-core/lib'
13
14const Plugin: VideoJSComponentInterface = videojs.getPlugin('plugin')
15class 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
32videojs.registerPlugin('p2pMediaLoader', P2pMediaLoaderPlugin)
33export { P2pMediaLoaderPlugin }