]>
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' |
5abc96fc C |
7 | import { PlayerMode } from './peertube-player-manager' |
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 | |
44 | ||
4e11d8f3 | 45 | stats (options?: StatsCardOptions): StatsForNerdsPlugin |
ff563914 | 46 | |
f5fcd9f7 | 47 | textTracks (): TextTrackList & { |
1151f521 | 48 | tracks_: (TextTrack & { id: string, label: string, src: string })[] |
f5fcd9f7 | 49 | } |
83fcadac | 50 | |
abb3097e | 51 | dock (options: { title: string, description: string }): void |
5abc96fc C |
52 | |
53 | upnext (options: Partial<EndCardOptions>): void | |
4572c3d0 C |
54 | |
55 | playlist (): PlaylistPlugin | |
f5fcd9f7 | 56 | } |
c6352f2c C |
57 | } |
58 | ||
83fcadac | 59 | export interface VideoJSTechHLS extends videojs.Tech { |
02b2e482 | 60 | hlsProvider: Html5Hlsjs |
83fcadac C |
61 | } |
62 | ||
63 | export interface HlsjsConfigHandlerOptions { | |
02b2e482 | 64 | hlsjsConfig?: HlsConfig |
83fcadac C |
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 | |
a9bfa85d C |
140 | |
141 | playerRefusedP2P: boolean | |
2adfc7ea C |
142 | } |
143 | ||
144 | type P2PMediaLoaderPluginOptions = { | |
da332417 | 145 | redundancyUrlManager: RedundancyUrlManager |
2adfc7ea C |
146 | type: string |
147 | src: string | |
f0a39880 C |
148 | |
149 | startTime: number | string | |
2adfc7ea C |
150 | } |
151 | ||
152 | type VideoJSPluginOptions = { | |
4572c3d0 C |
153 | playlist?: PlaylistPluginOptions |
154 | ||
2adfc7ea C |
155 | peertube: PeerTubePluginOptions |
156 | ||
157 | webtorrent?: WebtorrentPluginOptions | |
158 | ||
159 | p2pMediaLoader?: P2PMediaLoaderPluginOptions | |
c6352f2c C |
160 | } |
161 | ||
2adfc7ea | 162 | type LoadedQualityData = { |
9df52d66 | 163 | qualitySwitchCallback: (resolutionId: number, type: 'video') => void |
2adfc7ea C |
164 | qualityData: { |
165 | video: { | |
166 | id: number | |
167 | label: string | |
168 | selected: boolean | |
169 | }[] | |
170 | } | |
171 | } | |
172 | ||
173 | type ResolutionUpdateData = { | |
9df52d66 | 174 | auto: boolean |
2adfc7ea | 175 | resolutionId: number |
3b6f205c | 176 | id?: number |
2adfc7ea C |
177 | } |
178 | ||
179 | type AutoResolutionUpdateData = { | |
180 | possible: boolean | |
181 | } | |
182 | ||
3b6f205c | 183 | type PlayerNetworkInfo = { |
17152837 FC |
184 | source: 'webtorrent' | 'p2p-media-loader' |
185 | ||
09209296 C |
186 | http: { |
187 | downloadSpeed: number | |
188 | uploadSpeed: number | |
189 | downloaded: number | |
190 | uploaded: number | |
191 | } | |
192 | ||
3b6f205c C |
193 | p2p: { |
194 | downloadSpeed: number | |
195 | uploadSpeed: number | |
196 | downloaded: number | |
197 | uploaded: number | |
198 | numPeers: number | |
199 | } | |
4e11d8f3 C |
200 | |
201 | // In bytes | |
202 | bandwidthEstimate: number | |
3b6f205c C |
203 | } |
204 | ||
4572c3d0 C |
205 | type PlaylistItemOptions = { |
206 | element: VideoPlaylistElement | |
207 | ||
e367da94 | 208 | onClicked: () => void |
4572c3d0 C |
209 | } |
210 | ||
c6352f2c | 211 | export { |
3b6f205c | 212 | PlayerNetworkInfo, |
4572c3d0 | 213 | PlaylistItemOptions, |
a950e4c8 | 214 | NextPreviousVideoButtonOptions, |
2adfc7ea C |
215 | ResolutionUpdateData, |
216 | AutoResolutionUpdateData, | |
4572c3d0 | 217 | PlaylistPluginOptions, |
6e46de09 | 218 | VideoJSCaption, |
2adfc7ea C |
219 | UserWatching, |
220 | PeerTubePluginOptions, | |
221 | WebtorrentPluginOptions, | |
222 | P2PMediaLoaderPluginOptions, | |
e367da94 | 223 | PeerTubeResolution, |
2adfc7ea | 224 | VideoJSPluginOptions, |
83fcadac | 225 | LoadedQualityData, |
e367da94 | 226 | PeerTubeLinkButtonOptions |
c6352f2c | 227 | } |