]>
Commit | Line | Data |
---|---|---|
1 | import { HlsConfig, Level } from 'hls.js' | |
2 | import videojs from 'video.js' | |
3 | import { Engine } from '@peertube/p2p-media-loader-hlsjs' | |
4 | import { VideoFile, VideoPlaylist, VideoPlaylistElement } from '@shared/models' | |
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' | |
17 | ||
18 | declare module 'video.js' { | |
19 | ||
20 | export interface VideoJsPlayer { | |
21 | srOptions_: HlsjsConfigHandlerOptions | |
22 | ||
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 | ||
35 | peertube (): PeerTubePlugin | |
36 | ||
37 | webtorrent (): WebTorrentPlugin | |
38 | ||
39 | p2pMediaLoader (): P2pMediaLoaderPlugin | |
40 | ||
41 | peertubeResolutions (): PeerTubeResolutionsPlugin | |
42 | ||
43 | contextmenuUI (options: any): any | |
44 | ||
45 | bezels (): void | |
46 | peertubeMobile (): void | |
47 | peerTubeHotkeysPlugin (): void | |
48 | ||
49 | stats (options?: StatsCardOptions): StatsForNerdsPlugin | |
50 | ||
51 | textTracks (): TextTrackList & { | |
52 | tracks_: (TextTrack & { id: string, label: string, src: string })[] | |
53 | } | |
54 | ||
55 | peertubeDock (options: PeerTubeDockPluginOptions): void | |
56 | ||
57 | upnext (options: Partial<EndCardOptions>): void | |
58 | ||
59 | playlist (): PlaylistPlugin | |
60 | } | |
61 | } | |
62 | ||
63 | export interface VideoJSTechHLS extends videojs.Tech { | |
64 | hlsProvider: Html5Hlsjs | |
65 | } | |
66 | ||
67 | export interface HlsjsConfigHandlerOptions { | |
68 | hlsjsConfig?: HlsConfig | |
69 | ||
70 | levelLabelHandler?: (level: Level) => string | |
71 | } | |
72 | ||
73 | type PeerTubeResolution = { | |
74 | id: number | |
75 | ||
76 | height?: number | |
77 | label?: string | |
78 | width?: number | |
79 | bitrate?: number | |
80 | ||
81 | selected: boolean | |
82 | selectCallback: () => void | |
83 | } | |
84 | ||
85 | type VideoJSCaption = { | |
86 | label: string | |
87 | language: string | |
88 | src: string | |
89 | } | |
90 | ||
91 | type PeerTubePluginOptions = { | |
92 | mode: PlayerMode | |
93 | ||
94 | autoplay: boolean | |
95 | videoDuration: number | |
96 | ||
97 | videoViewUrl: string | |
98 | authorizationHeader?: string | |
99 | ||
100 | subtitle?: string | |
101 | ||
102 | videoCaptions: VideoJSCaption[] | |
103 | ||
104 | startTime: number | string | |
105 | stopTime: number | string | |
106 | ||
107 | isLive: boolean | |
108 | ||
109 | videoUUID: string | |
110 | } | |
111 | ||
112 | type PlaylistPluginOptions = { | |
113 | elements: VideoPlaylistElement[] | |
114 | ||
115 | playlist: VideoPlaylist | |
116 | ||
117 | getCurrentPosition: () => number | |
118 | ||
119 | onItemClicked: (element: VideoPlaylistElement) => void | |
120 | } | |
121 | ||
122 | type NextPreviousVideoButtonOptions = { | |
123 | type: 'next' | 'previous' | |
124 | handler: () => void | |
125 | isDisabled: () => boolean | |
126 | } | |
127 | ||
128 | type PeerTubeLinkButtonOptions = { | |
129 | shortUUID: string | |
130 | instanceName: 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 | loader: P2PMediaLoader | |
158 | } | |
159 | ||
160 | export type P2PMediaLoader = { | |
161 | getEngine(): Engine | |
162 | } | |
163 | ||
164 | type VideoJSPluginOptions = { | |
165 | playlist?: PlaylistPluginOptions | |
166 | ||
167 | peertube: PeerTubePluginOptions | |
168 | ||
169 | webtorrent?: WebtorrentPluginOptions | |
170 | ||
171 | p2pMediaLoader?: P2PMediaLoaderPluginOptions | |
172 | } | |
173 | ||
174 | type LoadedQualityData = { | |
175 | qualitySwitchCallback: (resolutionId: number, type: 'video') => void | |
176 | qualityData: { | |
177 | video: { | |
178 | id: number | |
179 | label: string | |
180 | selected: boolean | |
181 | }[] | |
182 | } | |
183 | } | |
184 | ||
185 | type ResolutionUpdateData = { | |
186 | auto: boolean | |
187 | resolutionId: number | |
188 | id?: number | |
189 | } | |
190 | ||
191 | type AutoResolutionUpdateData = { | |
192 | possible: boolean | |
193 | } | |
194 | ||
195 | type PlayerNetworkInfo = { | |
196 | source: 'webtorrent' | 'p2p-media-loader' | |
197 | ||
198 | http: { | |
199 | downloadSpeed: number | |
200 | uploadSpeed: number | |
201 | downloaded: number | |
202 | uploaded: number | |
203 | } | |
204 | ||
205 | p2p: { | |
206 | downloadSpeed: number | |
207 | uploadSpeed: number | |
208 | downloaded: number | |
209 | uploaded: number | |
210 | numPeers: number | |
211 | } | |
212 | ||
213 | // In bytes | |
214 | bandwidthEstimate: number | |
215 | } | |
216 | ||
217 | type PlaylistItemOptions = { | |
218 | element: VideoPlaylistElement | |
219 | ||
220 | onClicked: () => void | |
221 | } | |
222 | ||
223 | export { | |
224 | PlayerNetworkInfo, | |
225 | PlaylistItemOptions, | |
226 | NextPreviousVideoButtonOptions, | |
227 | ResolutionUpdateData, | |
228 | AutoResolutionUpdateData, | |
229 | PlaylistPluginOptions, | |
230 | VideoJSCaption, | |
231 | PeerTubePluginOptions, | |
232 | WebtorrentPluginOptions, | |
233 | P2PMediaLoaderPluginOptions, | |
234 | PeerTubeResolution, | |
235 | VideoJSPluginOptions, | |
236 | LoadedQualityData, | |
237 | PeerTubeLinkButtonOptions, | |
238 | PeerTubeP2PInfoButtonOptions | |
239 | } |