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