]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/assets/player/peertube-videojs-typings.ts
Improve HLS redundancy
[github/Chocobozzz/PeerTube.git] / client / src / assets / player / peertube-videojs-typings.ts
CommitLineData
c199c427
C
1// FIXME: something weird with our path definition in tsconfig and typings
2// @ts-ignore
3import * as videojs from 'video.js'
4
c6352f2c 5import { VideoFile } from '../../../../shared/models/videos/video.model'
2adfc7ea 6import { PeerTubePlugin } from './peertube-plugin'
09209296
C
7import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin'
8import { P2pMediaLoaderPlugin } from './p2p-media-loader/p2p-media-loader-plugin'
9import { PlayerMode } from './peertube-player-manager'
da332417 10import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager'
c6352f2c 11
6cca7360 12declare namespace videojs {
c6352f2c
C
13 interface Player {
14 peertube (): PeerTubePlugin
2adfc7ea 15 webtorrent (): WebTorrentPlugin
09209296 16 p2pMediaLoader (): P2pMediaLoaderPlugin
c6352f2c
C
17 }
18}
19
20interface VideoJSComponentInterface {
21 _player: videojs.Player
22
244b4ae3 23 new (player: videojs.Player, options?: any): any
c6352f2c 24
244b4ae3 25 registerComponent (name: string, obj: any): any
c6352f2c
C
26}
27
16f7022b
C
28type VideoJSCaption = {
29 label: string
30 language: string
31 src: string
32}
33
6e46de09
C
34type UserWatching = {
35 url: string,
36 authorizationHeader: string
37}
38
2adfc7ea 39type PeerTubePluginOptions = {
09209296
C
40 mode: PlayerMode
41
2adfc7ea 42 autoplay: boolean
c6352f2c
C
43 videoViewUrl: string
44 videoDuration: number
6e46de09
C
45
46 userWatching?: UserWatching
2adfc7ea
C
47 subtitle?: string
48
49 videoCaptions: VideoJSCaption[]
f0a39880
C
50
51 stopTime: number | string
2adfc7ea
C
52}
53
54type WebtorrentPluginOptions = {
55 playerElement: HTMLVideoElement
56
57 autoplay: boolean
58 videoDuration: number
59
60 videoFiles: VideoFile[]
f0a39880
C
61
62 startTime: number | string
2adfc7ea
C
63}
64
65type P2PMediaLoaderPluginOptions = {
da332417 66 redundancyUrlManager: RedundancyUrlManager
2adfc7ea
C
67 type: string
68 src: string
f0a39880
C
69
70 startTime: number | string
2adfc7ea
C
71}
72
73type VideoJSPluginOptions = {
74 peertube: PeerTubePluginOptions
75
76 webtorrent?: WebtorrentPluginOptions
77
78 p2pMediaLoader?: P2PMediaLoaderPluginOptions
c6352f2c
C
79}
80
81// videojs typings don't have some method we need
82const videojsUntyped = videojs as any
83
2adfc7ea
C
84type LoadedQualityData = {
85 qualitySwitchCallback: Function,
86 qualityData: {
87 video: {
88 id: number
89 label: string
90 selected: boolean
91 }[]
92 }
93}
94
95type ResolutionUpdateData = {
96 auto: boolean,
97 resolutionId: number
3b6f205c 98 id?: number
2adfc7ea
C
99}
100
101type AutoResolutionUpdateData = {
102 possible: boolean
103}
104
3b6f205c 105type PlayerNetworkInfo = {
09209296
C
106 http: {
107 downloadSpeed: number
108 uploadSpeed: number
109 downloaded: number
110 uploaded: number
111 }
112
3b6f205c
C
113 p2p: {
114 downloadSpeed: number
115 uploadSpeed: number
116 downloaded: number
117 uploaded: number
118 numPeers: number
119 }
120}
121
c6352f2c 122export {
3b6f205c 123 PlayerNetworkInfo,
2adfc7ea
C
124 ResolutionUpdateData,
125 AutoResolutionUpdateData,
c6352f2c 126 VideoJSComponentInterface,
16f7022b 127 videojsUntyped,
6e46de09 128 VideoJSCaption,
2adfc7ea
C
129 UserWatching,
130 PeerTubePluginOptions,
131 WebtorrentPluginOptions,
132 P2PMediaLoaderPluginOptions,
133 VideoJSPluginOptions,
134 LoadedQualityData
c6352f2c 135}