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