]>
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 | elements: VideoPlaylistElement[] | |
117 | ||
118 | playlist: VideoPlaylist | |
119 | ||
120 | getCurrentPosition: () => number | |
121 | ||
122 | onItemClicked: (element: VideoPlaylistElement) => void | |
123 | } | |
124 | ||
125 | type NextPreviousVideoButtonOptions = { | |
126 | type: 'next' | 'previous' | |
127 | handler: Function | |
128 | isDisabled: () => boolean | |
129 | } | |
130 | ||
131 | type WebtorrentPluginOptions = { | |
132 | playerElement: HTMLVideoElement | |
133 | ||
134 | autoplay: boolean | |
135 | videoDuration: number | |
136 | ||
137 | videoFiles: VideoFile[] | |
138 | ||
139 | startTime: number | string | |
140 | } | |
141 | ||
142 | type P2PMediaLoaderPluginOptions = { | |
143 | redundancyUrlManager: RedundancyUrlManager | |
144 | type: string | |
145 | src: string | |
146 | ||
147 | startTime: number | string | |
148 | } | |
149 | ||
150 | type VideoJSPluginOptions = { | |
151 | playlist?: PlaylistPluginOptions | |
152 | ||
153 | peertube: PeerTubePluginOptions | |
154 | ||
155 | webtorrent?: WebtorrentPluginOptions | |
156 | ||
157 | p2pMediaLoader?: P2PMediaLoaderPluginOptions | |
158 | } | |
159 | ||
160 | type LoadedQualityData = { | |
161 | qualitySwitchCallback: Function, | |
162 | qualityData: { | |
163 | video: { | |
164 | id: number | |
165 | label: string | |
166 | selected: boolean | |
167 | }[] | |
168 | } | |
169 | } | |
170 | ||
171 | type ResolutionUpdateData = { | |
172 | auto: boolean, | |
173 | resolutionId: number | |
174 | id?: number | |
175 | } | |
176 | ||
177 | type AutoResolutionUpdateData = { | |
178 | possible: boolean | |
179 | } | |
180 | ||
181 | type PlayerNetworkInfo = { | |
182 | source: 'webtorrent' | 'p2p-media-loader' | |
183 | ||
184 | http: { | |
185 | downloadSpeed: number | |
186 | uploadSpeed: number | |
187 | downloaded: number | |
188 | uploaded: number | |
189 | } | |
190 | ||
191 | p2p: { | |
192 | downloadSpeed: number | |
193 | uploadSpeed: number | |
194 | downloaded: number | |
195 | uploaded: number | |
196 | numPeers: number | |
197 | } | |
198 | } | |
199 | ||
200 | type PlaylistItemOptions = { | |
201 | element: VideoPlaylistElement | |
202 | ||
203 | onClicked: Function | |
204 | } | |
205 | ||
206 | export { | |
207 | PlayerNetworkInfo, | |
208 | PlaylistItemOptions, | |
209 | NextPreviousVideoButtonOptions, | |
210 | ResolutionUpdateData, | |
211 | AutoResolutionUpdateData, | |
212 | PlaylistPluginOptions, | |
213 | VideoJSCaption, | |
214 | UserWatching, | |
215 | PeerTubePluginOptions, | |
216 | WebtorrentPluginOptions, | |
217 | P2PMediaLoaderPluginOptions, | |
218 | VideoJSPluginOptions, | |
219 | LoadedQualityData, | |
220 | QualityLevelRepresentation, | |
221 | QualityLevels | |
222 | } |