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