]>
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 C |
9 | import { EndCardOptions } from './upnext/end-card' |
10 | import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin' | |
c6352f2c | 11 | |
f5fcd9f7 | 12 | declare module 'video.js' { |
83fcadac | 13 | |
f5fcd9f7 | 14 | export interface VideoJsPlayer { |
83fcadac C |
15 | srOptions_: HlsjsConfigHandlerOptions |
16 | ||
f5fcd9f7 C |
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 | ||
c6352f2c | 29 | peertube (): PeerTubePlugin |
83fcadac | 30 | |
2adfc7ea | 31 | webtorrent (): WebTorrentPlugin |
83fcadac | 32 | |
09209296 | 33 | p2pMediaLoader (): P2pMediaLoaderPlugin |
c6352f2c | 34 | |
f5fcd9f7 C |
35 | contextmenuUI (options: any): any |
36 | ||
37 | bezels (): void | |
38 | ||
83fcadac | 39 | qualityLevels (): QualityLevels |
c6352f2c | 40 | |
f5fcd9f7 C |
41 | textTracks (): TextTrackList & { |
42 | on: Function | |
1151f521 | 43 | tracks_: (TextTrack & { id: string, label: string, src: string })[] |
f5fcd9f7 | 44 | } |
83fcadac | 45 | |
abb3097e | 46 | dock (options: { title: string, description: string }): void |
5abc96fc C |
47 | |
48 | upnext (options: Partial<EndCardOptions>): void | |
4572c3d0 C |
49 | |
50 | playlist (): PlaylistPlugin | |
f5fcd9f7 | 51 | } |
c6352f2c C |
52 | } |
53 | ||
83fcadac C |
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 | ||
16f7022b C |
85 | type VideoJSCaption = { |
86 | label: string | |
87 | language: string | |
88 | src: string | |
89 | } | |
90 | ||
6e46de09 C |
91 | type UserWatching = { |
92 | url: string, | |
93 | authorizationHeader: string | |
94 | } | |
95 | ||
2adfc7ea | 96 | type PeerTubePluginOptions = { |
09209296 C |
97 | mode: PlayerMode |
98 | ||
2adfc7ea | 99 | autoplay: boolean |
c6352f2c C |
100 | videoViewUrl: string |
101 | videoDuration: number | |
6e46de09 C |
102 | |
103 | userWatching?: UserWatching | |
2adfc7ea C |
104 | subtitle?: string |
105 | ||
106 | videoCaptions: VideoJSCaption[] | |
f0a39880 C |
107 | |
108 | stopTime: number | string | |
10f26f42 C |
109 | |
110 | isLive: boolean | |
2adfc7ea C |
111 | } |
112 | ||
4572c3d0 C |
113 | type PlaylistPluginOptions = { |
114 | elements: VideoPlaylistElement[] | |
115 | ||
116 | playlist: VideoPlaylist | |
117 | ||
118 | getCurrentPosition: () => number | |
119 | ||
120 | onItemClicked: (element: VideoPlaylistElement) => void | |
121 | } | |
122 | ||
a950e4c8 C |
123 | type NextPreviousVideoButtonOptions = { |
124 | type: 'next' | 'previous' | |
125 | handler: Function | |
126 | isDisabled: () => boolean | |
127 | } | |
128 | ||
2adfc7ea C |
129 | type WebtorrentPluginOptions = { |
130 | playerElement: HTMLVideoElement | |
131 | ||
132 | autoplay: boolean | |
133 | videoDuration: number | |
134 | ||
135 | videoFiles: VideoFile[] | |
f0a39880 C |
136 | |
137 | startTime: number | string | |
2adfc7ea C |
138 | } |
139 | ||
140 | type P2PMediaLoaderPluginOptions = { | |
da332417 | 141 | redundancyUrlManager: RedundancyUrlManager |
2adfc7ea C |
142 | type: string |
143 | src: string | |
f0a39880 C |
144 | |
145 | startTime: number | string | |
2adfc7ea C |
146 | } |
147 | ||
148 | type VideoJSPluginOptions = { | |
4572c3d0 C |
149 | playlist?: PlaylistPluginOptions |
150 | ||
2adfc7ea C |
151 | peertube: PeerTubePluginOptions |
152 | ||
153 | webtorrent?: WebtorrentPluginOptions | |
154 | ||
155 | p2pMediaLoader?: P2PMediaLoaderPluginOptions | |
c6352f2c C |
156 | } |
157 | ||
2adfc7ea C |
158 | type LoadedQualityData = { |
159 | qualitySwitchCallback: Function, | |
160 | qualityData: { | |
161 | video: { | |
162 | id: number | |
163 | label: string | |
164 | selected: boolean | |
165 | }[] | |
166 | } | |
167 | } | |
168 | ||
169 | type ResolutionUpdateData = { | |
170 | auto: boolean, | |
171 | resolutionId: number | |
3b6f205c | 172 | id?: number |
2adfc7ea C |
173 | } |
174 | ||
175 | type AutoResolutionUpdateData = { | |
176 | possible: boolean | |
177 | } | |
178 | ||
3b6f205c | 179 | type PlayerNetworkInfo = { |
17152837 FC |
180 | source: 'webtorrent' | 'p2p-media-loader' |
181 | ||
09209296 C |
182 | http: { |
183 | downloadSpeed: number | |
184 | uploadSpeed: number | |
185 | downloaded: number | |
186 | uploaded: number | |
187 | } | |
188 | ||
3b6f205c C |
189 | p2p: { |
190 | downloadSpeed: number | |
191 | uploadSpeed: number | |
192 | downloaded: number | |
193 | uploaded: number | |
194 | numPeers: number | |
195 | } | |
196 | } | |
197 | ||
4572c3d0 C |
198 | type PlaylistItemOptions = { |
199 | element: VideoPlaylistElement | |
200 | ||
201 | onClicked: Function | |
202 | } | |
203 | ||
c6352f2c | 204 | export { |
3b6f205c | 205 | PlayerNetworkInfo, |
4572c3d0 | 206 | PlaylistItemOptions, |
a950e4c8 | 207 | NextPreviousVideoButtonOptions, |
2adfc7ea C |
208 | ResolutionUpdateData, |
209 | AutoResolutionUpdateData, | |
4572c3d0 | 210 | PlaylistPluginOptions, |
6e46de09 | 211 | VideoJSCaption, |
2adfc7ea C |
212 | UserWatching, |
213 | PeerTubePluginOptions, | |
214 | WebtorrentPluginOptions, | |
215 | P2PMediaLoaderPluginOptions, | |
216 | VideoJSPluginOptions, | |
83fcadac C |
217 | LoadedQualityData, |
218 | QualityLevelRepresentation, | |
219 | QualityLevels | |
c6352f2c | 220 | } |