]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/assets/player/peertube-videojs-typings.ts
Load embed api resolutions on init
[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 WebtorrentPluginOptions = {
136 playerElement: HTMLVideoElement
137
138 autoplay: boolean
139 videoDuration: number
140
141 videoFiles: VideoFile[]
142
143 startTime: number | string
144 }
145
146 type P2PMediaLoaderPluginOptions = {
147 redundancyUrlManager: RedundancyUrlManager
148 type: string
149 src: string
150
151 startTime: number | string
152 }
153
154 type VideoJSPluginOptions = {
155 playlist?: PlaylistPluginOptions
156
157 peertube: PeerTubePluginOptions
158
159 webtorrent?: WebtorrentPluginOptions
160
161 p2pMediaLoader?: P2PMediaLoaderPluginOptions
162 }
163
164 type LoadedQualityData = {
165 qualitySwitchCallback: Function,
166 qualityData: {
167 video: {
168 id: number
169 label: string
170 selected: boolean
171 }[]
172 }
173 }
174
175 type ResolutionUpdateData = {
176 auto: boolean,
177 resolutionId: number
178 id?: number
179 }
180
181 type AutoResolutionUpdateData = {
182 possible: boolean
183 }
184
185 type PlayerNetworkInfo = {
186 source: 'webtorrent' | 'p2p-media-loader'
187
188 http: {
189 downloadSpeed: number
190 uploadSpeed: number
191 downloaded: number
192 uploaded: number
193 }
194
195 p2p: {
196 downloadSpeed: number
197 uploadSpeed: number
198 downloaded: number
199 uploaded: number
200 numPeers: number
201 }
202
203 // In bytes
204 bandwidthEstimate: number
205 }
206
207 type PlaylistItemOptions = {
208 element: VideoPlaylistElement
209
210 onClicked: Function
211 }
212
213 export {
214 PlayerNetworkInfo,
215 PlaylistItemOptions,
216 NextPreviousVideoButtonOptions,
217 ResolutionUpdateData,
218 AutoResolutionUpdateData,
219 PlaylistPluginOptions,
220 VideoJSCaption,
221 UserWatching,
222 PeerTubePluginOptions,
223 WebtorrentPluginOptions,
224 P2PMediaLoaderPluginOptions,
225 VideoJSPluginOptions,
226 LoadedQualityData,
227 QualityLevelRepresentation,
228 QualityLevels
229 }