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