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