]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/assets/player/peertube-videojs-typings.ts
Try to fix mock server ports
[github/Chocobozzz/PeerTube.git] / client / src / assets / player / peertube-videojs-typings.ts
1 // FIXME: lint
2 /* eslint-disable @typescript-eslint/ban-types */
3
4 import { HlsConfig, Level } from 'hls.js'
5 import videojs from 'video.js'
6 import { VideoFile, VideoPlaylist, VideoPlaylistElement } from '@shared/models'
7 import { P2pMediaLoaderPlugin } from './p2p-media-loader/p2p-media-loader-plugin'
8 import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager'
9 import { PlayerMode } from './peertube-player-manager'
10 import { PeerTubePlugin } from './peertube-plugin'
11 import { PlaylistPlugin } from './playlist/playlist-plugin'
12 import { EndCardOptions } from './upnext/end-card'
13 import { StatsCardOptions } from './stats/stats-card'
14 import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin'
15 import { StatsForNerdsPlugin } from './stats/stats-plugin'
16
17 declare module 'video.js' {
18
19 export interface VideoJsPlayer {
20 srOptions_: HlsjsConfigHandlerOptions
21
22 theaterEnabled: boolean
23
24 // FIXME: add it to upstream typings
25 posterImage: {
26 show (): void
27 hide (): void
28 }
29
30 handleTechSeeked_ (): void
31
32 // Plugins
33
34 peertube (): PeerTubePlugin
35
36 webtorrent (): WebTorrentPlugin
37
38 p2pMediaLoader (): P2pMediaLoaderPlugin
39
40 contextmenuUI (options: any): any
41
42 bezels (): void
43
44 stats (options?: StatsCardOptions): StatsForNerdsPlugin
45
46 qualityLevels (): QualityLevels
47
48 textTracks (): TextTrackList & {
49 on: Function
50 tracks_: (TextTrack & { id: string, label: string, src: string })[]
51 }
52
53 dock (options: { title: string, description: string }): void
54
55 upnext (options: Partial<EndCardOptions>): void
56
57 playlist (): PlaylistPlugin
58 }
59 }
60
61 export interface VideoJSTechHLS extends videojs.Tech {
62 hlsProvider: any // FIXME: typings
63 }
64
65 export interface HlsjsConfigHandlerOptions {
66 hlsjsConfig?: HlsConfig & { cueHandler: any }// FIXME: typings
67 captionConfig?: any // FIXME: typings
68
69 levelLabelHandler?: (level: Level) => string
70 }
71
72 type QualityLevelRepresentation = {
73 id: number
74 height: number
75
76 label?: string
77 width?: number
78 bandwidth?: number
79 bitrate?: number
80
81 enabled?: Function
82 _enabled: boolean
83 }
84
85 type QualityLevels = QualityLevelRepresentation[] & {
86 selectedIndex: number
87 selectedIndex_: number
88
89 addQualityLevel (representation: QualityLevelRepresentation): void
90 }
91
92 type VideoJSCaption = {
93 label: string
94 language: string
95 src: string
96 }
97
98 type UserWatching = {
99 url: string
100 authorizationHeader: string
101 }
102
103 type PeerTubePluginOptions = {
104 mode: PlayerMode
105
106 autoplay: boolean
107 videoViewUrl: string
108 videoDuration: number
109
110 userWatching?: UserWatching
111 subtitle?: string
112
113 videoCaptions: VideoJSCaption[]
114
115 stopTime: number | string
116
117 isLive: boolean
118
119 videoUUID: string
120 }
121
122 type PlaylistPluginOptions = {
123 elements: VideoPlaylistElement[]
124
125 playlist: VideoPlaylist
126
127 getCurrentPosition: () => number
128
129 onItemClicked: (element: VideoPlaylistElement) => void
130 }
131
132 type NextPreviousVideoButtonOptions = {
133 type: 'next' | 'previous'
134 handler: Function
135 isDisabled: () => boolean
136 }
137
138 type PeerTubeLinkButtonOptions = {
139 shortUUID: string
140 }
141
142 type WebtorrentPluginOptions = {
143 playerElement: HTMLVideoElement
144
145 autoplay: boolean
146 videoDuration: number
147
148 videoFiles: VideoFile[]
149
150 startTime: number | string
151 }
152
153 type P2PMediaLoaderPluginOptions = {
154 redundancyUrlManager: RedundancyUrlManager
155 type: string
156 src: string
157
158 startTime: number | string
159 }
160
161 type VideoJSPluginOptions = {
162 playlist?: PlaylistPluginOptions
163
164 peertube: PeerTubePluginOptions
165
166 webtorrent?: WebtorrentPluginOptions
167
168 p2pMediaLoader?: P2PMediaLoaderPluginOptions
169 }
170
171 type LoadedQualityData = {
172 qualitySwitchCallback: (resolutionId: number, type: 'video') => void
173 qualityData: {
174 video: {
175 id: number
176 label: string
177 selected: boolean
178 }[]
179 }
180 }
181
182 type ResolutionUpdateData = {
183 auto: boolean
184 resolutionId: number
185 id?: number
186 }
187
188 type AutoResolutionUpdateData = {
189 possible: boolean
190 }
191
192 type PlayerNetworkInfo = {
193 source: 'webtorrent' | 'p2p-media-loader'
194
195 http: {
196 downloadSpeed: number
197 uploadSpeed: number
198 downloaded: number
199 uploaded: number
200 }
201
202 p2p: {
203 downloadSpeed: number
204 uploadSpeed: number
205 downloaded: number
206 uploaded: number
207 numPeers: number
208 }
209
210 // In bytes
211 bandwidthEstimate: number
212 }
213
214 type PlaylistItemOptions = {
215 element: VideoPlaylistElement
216
217 onClicked: Function
218 }
219
220 export {
221 PlayerNetworkInfo,
222 PlaylistItemOptions,
223 NextPreviousVideoButtonOptions,
224 ResolutionUpdateData,
225 AutoResolutionUpdateData,
226 PlaylistPluginOptions,
227 VideoJSCaption,
228 UserWatching,
229 PeerTubePluginOptions,
230 WebtorrentPluginOptions,
231 P2PMediaLoaderPluginOptions,
232 VideoJSPluginOptions,
233 LoadedQualityData,
234 QualityLevelRepresentation,
235 PeerTubeLinkButtonOptions,
236 QualityLevels
237 }