]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/assets/player/peertube-videojs-typings.ts
Refactor video links building
[github/Chocobozzz/PeerTube.git] / client / src / assets / player / peertube-videojs-typings.ts
1 import { Config, Level } from 'hls.js'
2 import videojs from 'video.js'
3 import { VideoFile, VideoPlaylist, VideoPlaylistElement } from '@shared/models'
4 import { P2pMediaLoaderPlugin } from './p2p-media-loader/p2p-media-loader-plugin'
5 import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager'
6 import { PlayerMode } from './peertube-player-manager'
7 import { PeerTubePlugin } from './peertube-plugin'
8 import { PlaylistPlugin } from './playlist/playlist-plugin'
9 import { EndCardOptions } from './upnext/end-card'
10 import { StatsCardOptions } from './stats/stats-card'
11 import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin'
12 import { StatsForNerdsPlugin } from './stats/stats-plugin'
13
14 declare module 'video.js' {
15
16 export interface VideoJsPlayer {
17 srOptions_: HlsjsConfigHandlerOptions
18
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
31 peertube (): PeerTubePlugin
32
33 webtorrent (): WebTorrentPlugin
34
35 p2pMediaLoader (): P2pMediaLoaderPlugin
36
37 contextmenuUI (options: any): any
38
39 bezels (): void
40
41 stats (options?: StatsCardOptions): StatsForNerdsPlugin
42
43 qualityLevels (): QualityLevels
44
45 textTracks (): TextTrackList & {
46 on: Function
47 tracks_: (TextTrack & { id: string, label: string, src: string })[]
48 }
49
50 dock (options: { title: string, description: string }): void
51
52 upnext (options: Partial<EndCardOptions>): void
53
54 playlist (): PlaylistPlugin
55 }
56 }
57
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
89 type VideoJSCaption = {
90 label: string
91 language: string
92 src: string
93 }
94
95 type UserWatching = {
96 url: string,
97 authorizationHeader: string
98 }
99
100 type PeerTubePluginOptions = {
101 mode: PlayerMode
102
103 autoplay: boolean
104 videoViewUrl: string
105 videoDuration: number
106
107 userWatching?: UserWatching
108 subtitle?: string
109
110 videoCaptions: VideoJSCaption[]
111
112 stopTime: number | string
113
114 isLive: boolean
115
116 videoUUID: string
117 }
118
119 type PlaylistPluginOptions = {
120 elements: VideoPlaylistElement[]
121
122 playlist: VideoPlaylist
123
124 getCurrentPosition: () => number
125
126 onItemClicked: (element: VideoPlaylistElement) => void
127 }
128
129 type NextPreviousVideoButtonOptions = {
130 type: 'next' | 'previous'
131 handler: Function
132 isDisabled: () => boolean
133 }
134
135 type PeerTubeLinkButtonOptions = {
136 shortUUID: string
137 }
138
139 type WebtorrentPluginOptions = {
140 playerElement: HTMLVideoElement
141
142 autoplay: boolean
143 videoDuration: number
144
145 videoFiles: VideoFile[]
146
147 startTime: number | string
148 }
149
150 type P2PMediaLoaderPluginOptions = {
151 redundancyUrlManager: RedundancyUrlManager
152 type: string
153 src: string
154
155 startTime: number | string
156 }
157
158 type VideoJSPluginOptions = {
159 playlist?: PlaylistPluginOptions
160
161 peertube: PeerTubePluginOptions
162
163 webtorrent?: WebtorrentPluginOptions
164
165 p2pMediaLoader?: P2PMediaLoaderPluginOptions
166 }
167
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
182 id?: number
183 }
184
185 type AutoResolutionUpdateData = {
186 possible: boolean
187 }
188
189 type PlayerNetworkInfo = {
190 source: 'webtorrent' | 'p2p-media-loader'
191
192 http: {
193 downloadSpeed: number
194 uploadSpeed: number
195 downloaded: number
196 uploaded: number
197 }
198
199 p2p: {
200 downloadSpeed: number
201 uploadSpeed: number
202 downloaded: number
203 uploaded: number
204 numPeers: number
205 }
206
207 // In bytes
208 bandwidthEstimate: number
209 }
210
211 type PlaylistItemOptions = {
212 element: VideoPlaylistElement
213
214 onClicked: Function
215 }
216
217 export {
218 PlayerNetworkInfo,
219 PlaylistItemOptions,
220 NextPreviousVideoButtonOptions,
221 ResolutionUpdateData,
222 AutoResolutionUpdateData,
223 PlaylistPluginOptions,
224 VideoJSCaption,
225 UserWatching,
226 PeerTubePluginOptions,
227 WebtorrentPluginOptions,
228 P2PMediaLoaderPluginOptions,
229 VideoJSPluginOptions,
230 LoadedQualityData,
231 QualityLevelRepresentation,
232 PeerTubeLinkButtonOptions,
233 QualityLevels
234 }