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