]>
Commit | Line | Data |
---|---|---|
3e254de8 | 1 | import { HlsConfig, Level } from 'hls.js' |
5abc96fc | 2 | import videojs from 'video.js' |
4572c3d0 | 3 | import { VideoFile, VideoPlaylist, VideoPlaylistElement } from '@shared/models' |
02b2e482 | 4 | import { Html5Hlsjs } from './p2p-media-loader/hls-plugin' |
09209296 | 5 | import { P2pMediaLoaderPlugin } from './p2p-media-loader/p2p-media-loader-plugin' |
da332417 | 6 | import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager' |
c4207f97 | 7 | import { PlayerMode } from './peertube-player-options-builder' |
5abc96fc | 8 | import { PeerTubePlugin } from './peertube-plugin' |
e367da94 | 9 | import { PeerTubeResolutionsPlugin } from './peertube-resolutions-plugin' |
4572c3d0 | 10 | import { PlaylistPlugin } from './playlist/playlist-plugin' |
ff563914 | 11 | import { StatsCardOptions } from './stats/stats-card' |
4e11d8f3 | 12 | import { StatsForNerdsPlugin } from './stats/stats-plugin' |
e367da94 C |
13 | import { EndCardOptions } from './upnext/end-card' |
14 | import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin' | |
c6352f2c | 15 | |
f5fcd9f7 | 16 | declare module 'video.js' { |
83fcadac | 17 | |
f5fcd9f7 | 18 | export interface VideoJsPlayer { |
83fcadac C |
19 | srOptions_: HlsjsConfigHandlerOptions |
20 | ||
f5fcd9f7 C |
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 | ||
c6352f2c | 33 | peertube (): PeerTubePlugin |
83fcadac | 34 | |
2adfc7ea | 35 | webtorrent (): WebTorrentPlugin |
83fcadac | 36 | |
09209296 | 37 | p2pMediaLoader (): P2pMediaLoaderPlugin |
c6352f2c | 38 | |
e367da94 C |
39 | peertubeResolutions (): PeerTubeResolutionsPlugin |
40 | ||
f5fcd9f7 C |
41 | contextmenuUI (options: any): any |
42 | ||
43 | bezels (): void | |
f1a0555a | 44 | peertubeMobile (): void |
d7b052ff | 45 | peerTubeHotkeysPlugin (): void |
f1a0555a | 46 | |
4e11d8f3 | 47 | stats (options?: StatsCardOptions): StatsForNerdsPlugin |
ff563914 | 48 | |
f5fcd9f7 | 49 | textTracks (): TextTrackList & { |
1151f521 | 50 | tracks_: (TextTrack & { id: string, label: string, src: string })[] |
f5fcd9f7 | 51 | } |
83fcadac | 52 | |
abb3097e | 53 | dock (options: { title: string, description: string }): void |
5abc96fc C |
54 | |
55 | upnext (options: Partial<EndCardOptions>): void | |
4572c3d0 C |
56 | |
57 | playlist (): PlaylistPlugin | |
f5fcd9f7 | 58 | } |
c6352f2c C |
59 | } |
60 | ||
83fcadac | 61 | export interface VideoJSTechHLS extends videojs.Tech { |
02b2e482 | 62 | hlsProvider: Html5Hlsjs |
83fcadac C |
63 | } |
64 | ||
65 | export interface HlsjsConfigHandlerOptions { | |
02b2e482 | 66 | hlsjsConfig?: HlsConfig |
83fcadac C |
67 | |
68 | levelLabelHandler?: (level: Level) => string | |
69 | } | |
70 | ||
e367da94 | 71 | type PeerTubeResolution = { |
83fcadac | 72 | id: number |
83fcadac | 73 | |
e367da94 | 74 | height?: number |
83fcadac C |
75 | label?: string |
76 | width?: number | |
83fcadac C |
77 | bitrate?: number |
78 | ||
e367da94 C |
79 | selected: boolean |
80 | selectCallback: () => void | |
83fcadac C |
81 | } |
82 | ||
16f7022b C |
83 | type VideoJSCaption = { |
84 | label: string | |
85 | language: string | |
86 | src: string | |
87 | } | |
88 | ||
6e46de09 | 89 | type UserWatching = { |
9df52d66 | 90 | url: string |
6e46de09 C |
91 | authorizationHeader: string |
92 | } | |
93 | ||
2adfc7ea | 94 | type PeerTubePluginOptions = { |
09209296 C |
95 | mode: PlayerMode |
96 | ||
2adfc7ea | 97 | autoplay: boolean |
c6352f2c C |
98 | videoViewUrl: string |
99 | videoDuration: number | |
6e46de09 C |
100 | |
101 | userWatching?: UserWatching | |
2adfc7ea C |
102 | subtitle?: string |
103 | ||
104 | videoCaptions: VideoJSCaption[] | |
f0a39880 C |
105 | |
106 | stopTime: number | string | |
10f26f42 C |
107 | |
108 | isLive: boolean | |
58b9ce30 | 109 | |
110 | videoUUID: string | |
2adfc7ea C |
111 | } |
112 | ||
4572c3d0 | 113 | type PlaylistPluginOptions = { |
3e0e8d4a | 114 | elements: VideoPlaylistElement[] |
4572c3d0 C |
115 | |
116 | playlist: VideoPlaylist | |
117 | ||
118 | getCurrentPosition: () => number | |
119 | ||
3e0e8d4a | 120 | onItemClicked: (element: VideoPlaylistElement) => void |
4572c3d0 C |
121 | } |
122 | ||
a950e4c8 C |
123 | type NextPreviousVideoButtonOptions = { |
124 | type: 'next' | 'previous' | |
e367da94 | 125 | handler: () => void |
a950e4c8 C |
126 | isDisabled: () => boolean |
127 | } | |
128 | ||
9162fdd3 C |
129 | type PeerTubeLinkButtonOptions = { |
130 | shortUUID: string | |
131 | } | |
132 | ||
bf1c3c78 C |
133 | type PeerTubeP2PInfoButtonOptions = { |
134 | p2pEnabled: boolean | |
135 | } | |
136 | ||
2adfc7ea C |
137 | type WebtorrentPluginOptions = { |
138 | playerElement: HTMLVideoElement | |
139 | ||
140 | autoplay: boolean | |
141 | videoDuration: number | |
142 | ||
143 | videoFiles: VideoFile[] | |
f0a39880 C |
144 | |
145 | startTime: number | string | |
a9bfa85d C |
146 | |
147 | playerRefusedP2P: boolean | |
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 | 168 | type LoadedQualityData = { |
9df52d66 | 169 | qualitySwitchCallback: (resolutionId: number, type: 'video') => void |
2adfc7ea C |
170 | qualityData: { |
171 | video: { | |
172 | id: number | |
173 | label: string | |
174 | selected: boolean | |
175 | }[] | |
176 | } | |
177 | } | |
178 | ||
179 | type ResolutionUpdateData = { | |
9df52d66 | 180 | auto: boolean |
2adfc7ea | 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 | ||
e367da94 | 214 | onClicked: () => void |
4572c3d0 C |
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, | |
e367da94 | 229 | PeerTubeResolution, |
2adfc7ea | 230 | VideoJSPluginOptions, |
83fcadac | 231 | LoadedQualityData, |
bf1c3c78 C |
232 | PeerTubeLinkButtonOptions, |
233 | PeerTubeP2PInfoButtonOptions | |
c6352f2c | 234 | } |