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