]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/assets/player/peertube-videojs-typings.ts
cf92e5f08a4b626fcb8b31be11e17d2380eb45f9
[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
13 declare module 'video.js' {
14
15 export interface VideoJsPlayer {
16 srOptions_: HlsjsConfigHandlerOptions
17
18 theaterEnabled: boolean
19
20 // FIXME: add it to upstream typings
21 posterImage: {
22 show (): void
23 hide (): void
24 }
25
26 handleTechSeeked_ (): void
27
28 // Plugins
29
30 peertube (): PeerTubePlugin
31
32 webtorrent (): WebTorrentPlugin
33
34 p2pMediaLoader (): P2pMediaLoaderPlugin
35
36 contextmenuUI (options: any): any
37
38 bezels (): void
39
40 stats (options?: Partial<StatsCardOptions>): any
41
42 qualityLevels (): QualityLevels
43
44 textTracks (): TextTrackList & {
45 on: Function
46 tracks_: (TextTrack & { id: string, label: string, src: string })[]
47 }
48
49 dock (options: { title: string, description: string }): void
50
51 upnext (options: Partial<EndCardOptions>): void
52
53 playlist (): PlaylistPlugin
54 }
55 }
56
57 export interface VideoJSTechHLS extends videojs.Tech {
58 hlsProvider: any // FIXME: typings
59 }
60
61 export interface HlsjsConfigHandlerOptions {
62 hlsjsConfig?: Config & { cueHandler: any }// FIXME: typings
63 captionConfig?: any // FIXME: typings
64
65 levelLabelHandler?: (level: Level) => string
66 }
67
68 type QualityLevelRepresentation = {
69 id: number
70 height: number
71
72 label?: string
73 width?: number
74 bandwidth?: number
75 bitrate?: number
76
77 enabled?: Function
78 _enabled: boolean
79 }
80
81 type QualityLevels = QualityLevelRepresentation[] & {
82 selectedIndex: number
83 selectedIndex_: number
84
85 addQualityLevel (representation: QualityLevelRepresentation): void
86 }
87
88 type VideoJSCaption = {
89 label: string
90 language: string
91 src: string
92 }
93
94 type UserWatching = {
95 url: string,
96 authorizationHeader: string
97 }
98
99 type PeerTubePluginOptions = {
100 mode: PlayerMode
101
102 autoplay: boolean
103 videoViewUrl: string
104 videoDuration: number
105
106 userWatching?: UserWatching
107 subtitle?: string
108
109 videoCaptions: VideoJSCaption[]
110
111 stopTime: number | string
112
113 isLive: boolean
114
115 videoUUID: string
116 }
117
118 type PlaylistPluginOptions = {
119 elements: VideoPlaylistElement[]
120
121 playlist: VideoPlaylist
122
123 getCurrentPosition: () => number
124
125 onItemClicked: (element: VideoPlaylistElement) => void
126 }
127
128 type NextPreviousVideoButtonOptions = {
129 type: 'next' | 'previous'
130 handler: Function
131 isDisabled: () => boolean
132 }
133
134 type WebtorrentPluginOptions = {
135 playerElement: HTMLVideoElement
136
137 autoplay: boolean
138 videoDuration: number
139
140 videoFiles: VideoFile[]
141
142 startTime: number | string
143 }
144
145 type P2PMediaLoaderPluginOptions = {
146 redundancyUrlManager: RedundancyUrlManager
147 type: string
148 src: string
149
150 startTime: number | string
151 }
152
153 type VideoJSPluginOptions = {
154 playlist?: PlaylistPluginOptions
155
156 peertube: PeerTubePluginOptions
157
158 webtorrent?: WebtorrentPluginOptions
159
160 p2pMediaLoader?: P2PMediaLoaderPluginOptions
161 }
162
163 type LoadedQualityData = {
164 qualitySwitchCallback: Function,
165 qualityData: {
166 video: {
167 id: number
168 label: string
169 selected: boolean
170 }[]
171 }
172 }
173
174 type ResolutionUpdateData = {
175 auto: boolean,
176 resolutionId: number
177 id?: number
178 }
179
180 type AutoResolutionUpdateData = {
181 possible: boolean
182 }
183
184 type PlayerNetworkInfo = {
185 source: 'webtorrent' | 'p2p-media-loader'
186
187 http: {
188 downloadSpeed: number
189 uploadSpeed: number
190 downloaded: number
191 uploaded: number
192 }
193
194 p2p: {
195 downloadSpeed: number
196 uploadSpeed: number
197 downloaded: number
198 uploaded: number
199 numPeers: number
200 }
201 }
202
203 type PlaylistItemOptions = {
204 element: VideoPlaylistElement
205
206 onClicked: Function
207 }
208
209 export {
210 PlayerNetworkInfo,
211 PlaylistItemOptions,
212 NextPreviousVideoButtonOptions,
213 ResolutionUpdateData,
214 AutoResolutionUpdateData,
215 PlaylistPluginOptions,
216 VideoJSCaption,
217 UserWatching,
218 PeerTubePluginOptions,
219 WebtorrentPluginOptions,
220 P2PMediaLoaderPluginOptions,
221 VideoJSPluginOptions,
222 LoadedQualityData,
223 QualityLevelRepresentation,
224 QualityLevels
225 }