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