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