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