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