]>
Commit | Line | Data |
---|---|---|
1 | import { HlsConfig, Level } from 'hls.js' | |
2 | import videojs from 'video.js' | |
3 | import { VideoFile, VideoPlaylist, VideoPlaylistElement } from '@shared/models' | |
4 | import { PeerTubeDockPluginOptions } from './dock/peertube-dock-plugin' | |
5 | import { Html5Hlsjs } from './p2p-media-loader/hls-plugin' | |
6 | import { P2pMediaLoaderPlugin } from './p2p-media-loader/p2p-media-loader-plugin' | |
7 | import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager' | |
8 | import { PlayerMode } from './peertube-player-options-builder' | |
9 | import { PeerTubePlugin } from './peertube-plugin' | |
10 | import { PeerTubeResolutionsPlugin } from './peertube-resolutions-plugin' | |
11 | import { PlaylistPlugin } from './playlist/playlist-plugin' | |
12 | import { StatsCardOptions } from './stats/stats-card' | |
13 | import { StatsForNerdsPlugin } from './stats/stats-plugin' | |
14 | import { EndCardOptions } from './upnext/end-card' | |
15 | import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin' | |
16 | ||
17 | declare 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 | ||
62 | export interface VideoJSTechHLS extends videojs.Tech { | |
63 | hlsProvider: Html5Hlsjs | |
64 | } | |
65 | ||
66 | export interface HlsjsConfigHandlerOptions { | |
67 | hlsjsConfig?: HlsConfig | |
68 | ||
69 | levelLabelHandler?: (level: Level) => string | |
70 | } | |
71 | ||
72 | type 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 | ||
84 | type VideoJSCaption = { | |
85 | label: string | |
86 | language: string | |
87 | src: string | |
88 | } | |
89 | ||
90 | type UserWatching = { | |
91 | url: string | |
92 | authorizationHeader: string | |
93 | } | |
94 | ||
95 | type 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 | ||
114 | type PlaylistPluginOptions = { | |
115 | elements: VideoPlaylistElement[] | |
116 | ||
117 | playlist: VideoPlaylist | |
118 | ||
119 | getCurrentPosition: () => number | |
120 | ||
121 | onItemClicked: (element: VideoPlaylistElement) => void | |
122 | } | |
123 | ||
124 | type NextPreviousVideoButtonOptions = { | |
125 | type: 'next' | 'previous' | |
126 | handler: () => void | |
127 | isDisabled: () => boolean | |
128 | } | |
129 | ||
130 | type PeerTubeLinkButtonOptions = { | |
131 | shortUUID: string | |
132 | } | |
133 | ||
134 | type PeerTubeP2PInfoButtonOptions = { | |
135 | p2pEnabled: boolean | |
136 | } | |
137 | ||
138 | type 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 | ||
151 | type P2PMediaLoaderPluginOptions = { | |
152 | redundancyUrlManager: RedundancyUrlManager | |
153 | type: string | |
154 | src: string | |
155 | ||
156 | startTime: number | string | |
157 | } | |
158 | ||
159 | type VideoJSPluginOptions = { | |
160 | playlist?: PlaylistPluginOptions | |
161 | ||
162 | peertube: PeerTubePluginOptions | |
163 | ||
164 | webtorrent?: WebtorrentPluginOptions | |
165 | ||
166 | p2pMediaLoader?: P2PMediaLoaderPluginOptions | |
167 | } | |
168 | ||
169 | type 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 | ||
180 | type ResolutionUpdateData = { | |
181 | auto: boolean | |
182 | resolutionId: number | |
183 | id?: number | |
184 | } | |
185 | ||
186 | type AutoResolutionUpdateData = { | |
187 | possible: boolean | |
188 | } | |
189 | ||
190 | type 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 | ||
212 | type PlaylistItemOptions = { | |
213 | element: VideoPlaylistElement | |
214 | ||
215 | onClicked: () => void | |
216 | } | |
217 | ||
218 | export { | |
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 | } |