aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/p2p-media-loader
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-01-28 17:29:50 +0100
committerChocobozzz <me@florianbigard.com>2020-01-29 11:48:15 +0100
commitf5fcd9f72514d6c4044a9c904d0ce610033bcba5 (patch)
tree241b7f0dd4435fa4451b1bd70a2103e092369c8c /client/src/assets/player/p2p-media-loader
parent0374b6b5cd685316f924874b2a3068bb345eb0dd (diff)
downloadPeerTube-f5fcd9f72514d6c4044a9c904d0ce610033bcba5.tar.gz
PeerTube-f5fcd9f72514d6c4044a9c904d0ce610033bcba5.tar.zst
PeerTube-f5fcd9f72514d6c4044a9c904d0ce610033bcba5.zip
Correctly type videojs player
Diffstat (limited to 'client/src/assets/player/p2p-media-loader')
-rw-r--r--client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts23
1 files changed, 12 insertions, 11 deletions
diff --git a/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts b/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts
index c3f863f72..512054ae6 100644
--- a/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts
+++ b/client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts
@@ -1,7 +1,5 @@
1// FIXME: something weird with our path definition in tsconfig and typings 1import videojs, { VideoJsPlayer } from 'video.js'
2// @ts-ignore 2import { P2PMediaLoaderPluginOptions, PlayerNetworkInfo } from '../peertube-videojs-typings'
3import * as videojs from 'video.js'
4import { P2PMediaLoaderPluginOptions, PlayerNetworkInfo, VideoJSComponentInterface } from '../peertube-videojs-typings'
5import { Engine, initHlsJsPlayer, initVideoJsContribHlsJsPlayer } from 'p2p-media-loader-hlsjs' 3import { Engine, initHlsJsPlayer, initVideoJsContribHlsJsPlayer } from 'p2p-media-loader-hlsjs'
6import { Events, Segment } from 'p2p-media-loader-core' 4import { Events, Segment } from 'p2p-media-loader-core'
7import { timeToInt } from '../utils' 5import { timeToInt } from '../utils'
@@ -10,7 +8,7 @@ import { timeToInt } from '../utils'
10window['videojs'] = videojs 8window['videojs'] = videojs
11require('@streamroot/videojs-hlsjs-plugin') 9require('@streamroot/videojs-hlsjs-plugin')
12 10
13const Plugin: VideoJSComponentInterface = videojs.getPlugin('plugin') 11const Plugin = videojs.getPlugin('plugin')
14class P2pMediaLoaderPlugin extends Plugin { 12class P2pMediaLoaderPlugin extends Plugin {
15 13
16 private readonly CONSTANTS = { 14 private readonly CONSTANTS = {
@@ -37,12 +35,13 @@ class P2pMediaLoaderPlugin extends Plugin {
37 35
38 private networkInfoInterval: any 36 private networkInfoInterval: any
39 37
40 constructor (player: videojs.Player, options: P2PMediaLoaderPluginOptions) { 38 constructor (player: VideoJsPlayer, options?: P2PMediaLoaderPluginOptions) {
41 super(player, options) 39 super(player)
42 40
43 this.options = options 41 this.options = options
44 42
45 if (!videojs.Html5Hlsjs) { 43 // FIXME: typings https://github.com/Microsoft/TypeScript/issues/14080
44 if (!(videojs as any).Html5Hlsjs) {
46 const message = 'HLS.js does not seem to be supported.' 45 const message = 'HLS.js does not seem to be supported.'
47 console.warn(message) 46 console.warn(message)
48 47
@@ -50,7 +49,8 @@ class P2pMediaLoaderPlugin extends Plugin {
50 return 49 return
51 } 50 }
52 51
53 videojs.Html5Hlsjs.addHook('beforeinitialize', (videojsPlayer: any, hlsjs: any) => { 52 // FIXME: typings https://github.com/Microsoft/TypeScript/issues/14080
53 (videojs as any).Html5Hlsjs.addHook('beforeinitialize', (videojsPlayer: any, hlsjs: any) => {
54 this.hlsjs = hlsjs 54 this.hlsjs = hlsjs
55 }) 55 })
56 56
@@ -84,8 +84,9 @@ class P2pMediaLoaderPlugin extends Plugin {
84 private initialize () { 84 private initialize () {
85 initHlsJsPlayer(this.hlsjs) 85 initHlsJsPlayer(this.hlsjs)
86 86
87 const tech = this.player.tech_ 87 // FIXME: typings
88 this.p2pEngine = tech.options_.hlsjsConfig.loader.getEngine() 88 const options = this.player.tech(true).options_ as any
89 this.p2pEngine = options.hlsjsConfig.loader.getEngine()
89 90
90 // Avoid using constants to not import hls.hs 91 // Avoid using constants to not import hls.hs
91 // https://github.com/video-dev/hls.js/blob/master/src/events.js#L37 92 // https://github.com/video-dev/hls.js/blob/master/src/events.js#L37