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