]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/assets/player/types/peertube-videojs-typings.ts
Merge branch 'release/4.2.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / assets / player / types / peertube-videojs-typings.ts
CommitLineData
3e254de8 1import { HlsConfig, Level } from 'hls.js'
5abc96fc 2import videojs from 'video.js'
9597920e 3import { Engine } from '@peertube/p2p-media-loader-hlsjs'
4572c3d0 4import { VideoFile, VideoPlaylist, VideoPlaylistElement } from '@shared/models'
57d65032
C
5import { PeerTubeDockPluginOptions } from '../shared/dock/peertube-dock-plugin'
6import { Html5Hlsjs } from '../shared/p2p-media-loader/hls-plugin'
7import { P2pMediaLoaderPlugin } from '../shared/p2p-media-loader/p2p-media-loader-plugin'
8import { RedundancyUrlManager } from '../shared/p2p-media-loader/redundancy-url-manager'
9import { PeerTubePlugin } from '../shared/peertube/peertube-plugin'
10import { PlaylistPlugin } from '../shared/playlist/playlist-plugin'
11import { PeerTubeResolutionsPlugin } from '../shared/resolutions/peertube-resolutions-plugin'
12import { StatsCardOptions } from '../shared/stats/stats-card'
13import { StatsForNerdsPlugin } from '../shared/stats/stats-plugin'
14import { EndCardOptions } from '../shared/upnext/end-card'
15import { WebTorrentPlugin } from '../shared/webtorrent/webtorrent-plugin'
16import { PlayerMode } from './manager-options'
c6352f2c 17
f5fcd9f7 18declare module 'video.js' {
83fcadac 19
f5fcd9f7 20 export interface VideoJsPlayer {
83fcadac
C
21 srOptions_: HlsjsConfigHandlerOptions
22
f5fcd9f7
C
23 theaterEnabled: boolean
24
25 // FIXME: add it to upstream typings
26 posterImage: {
27 show (): void
28 hide (): void
29 }
30
31 handleTechSeeked_ (): void
32
33 // Plugins
34
c6352f2c 35 peertube (): PeerTubePlugin
83fcadac 36
2adfc7ea 37 webtorrent (): WebTorrentPlugin
83fcadac 38
09209296 39 p2pMediaLoader (): P2pMediaLoaderPlugin
c6352f2c 40
e367da94
C
41 peertubeResolutions (): PeerTubeResolutionsPlugin
42
f5fcd9f7
C
43 contextmenuUI (options: any): any
44
45 bezels (): void
f1a0555a 46 peertubeMobile (): void
d7b052ff 47 peerTubeHotkeysPlugin (): void
f1a0555a 48
4e11d8f3 49 stats (options?: StatsCardOptions): StatsForNerdsPlugin
ff563914 50
f5fcd9f7 51 textTracks (): TextTrackList & {
1151f521 52 tracks_: (TextTrack & { id: string, label: string, src: string })[]
f5fcd9f7 53 }
83fcadac 54
01dd04cd 55 peertubeDock (options: PeerTubeDockPluginOptions): void
5abc96fc
C
56
57 upnext (options: Partial<EndCardOptions>): void
4572c3d0
C
58
59 playlist (): PlaylistPlugin
f5fcd9f7 60 }
c6352f2c
C
61}
62
83fcadac 63export interface VideoJSTechHLS extends videojs.Tech {
02b2e482 64 hlsProvider: Html5Hlsjs
83fcadac
C
65}
66
67export interface HlsjsConfigHandlerOptions {
02b2e482 68 hlsjsConfig?: HlsConfig
83fcadac
C
69
70 levelLabelHandler?: (level: Level) => string
71}
72
e367da94 73type PeerTubeResolution = {
83fcadac 74 id: number
83fcadac 75
e367da94 76 height?: number
83fcadac
C
77 label?: string
78 width?: number
83fcadac
C
79 bitrate?: number
80
e367da94
C
81 selected: boolean
82 selectCallback: () => void
83fcadac
C
83}
84
16f7022b
C
85type VideoJSCaption = {
86 label: string
87 language: string
88 src: string
89}
90
2adfc7ea 91type PeerTubePluginOptions = {
09209296
C
92 mode: PlayerMode
93
2adfc7ea 94 autoplay: boolean
c6352f2c 95 videoDuration: number
6e46de09 96
384ba8b7
C
97 videoViewUrl: string
98 authorizationHeader?: string
99
2adfc7ea
C
100 subtitle?: string
101
102 videoCaptions: VideoJSCaption[]
f0a39880 103
384ba8b7 104 startTime: number | string
f0a39880 105 stopTime: number | string
10f26f42
C
106
107 isLive: boolean
58b9ce30 108
109 videoUUID: string
2adfc7ea
C
110}
111
4572c3d0 112type PlaylistPluginOptions = {
3e0e8d4a 113 elements: VideoPlaylistElement[]
4572c3d0
C
114
115 playlist: VideoPlaylist
116
117 getCurrentPosition: () => number
118
3e0e8d4a 119 onItemClicked: (element: VideoPlaylistElement) => void
4572c3d0
C
120}
121
a950e4c8
C
122type NextPreviousVideoButtonOptions = {
123 type: 'next' | 'previous'
e367da94 124 handler: () => void
a950e4c8
C
125 isDisabled: () => boolean
126}
127
9162fdd3
C
128type PeerTubeLinkButtonOptions = {
129 shortUUID: string
bd2b51be 130 instanceName: string
9162fdd3
C
131}
132
bf1c3c78
C
133type PeerTubeP2PInfoButtonOptions = {
134 p2pEnabled: boolean
135}
136
2adfc7ea
C
137type WebtorrentPluginOptions = {
138 playerElement: HTMLVideoElement
139
140 autoplay: boolean
141 videoDuration: number
142
143 videoFiles: VideoFile[]
f0a39880
C
144
145 startTime: number | string
a9bfa85d
C
146
147 playerRefusedP2P: boolean
2adfc7ea
C
148}
149
150type P2PMediaLoaderPluginOptions = {
da332417 151 redundancyUrlManager: RedundancyUrlManager
2adfc7ea
C
152 type: string
153 src: string
f0a39880
C
154
155 startTime: number | string
9597920e
C
156
157 loader: P2PMediaLoader
158}
159
160export type P2PMediaLoader = {
161 getEngine(): Engine
2adfc7ea
C
162}
163
164type VideoJSPluginOptions = {
4572c3d0
C
165 playlist?: PlaylistPluginOptions
166
2adfc7ea
C
167 peertube: PeerTubePluginOptions
168
169 webtorrent?: WebtorrentPluginOptions
170
171 p2pMediaLoader?: P2PMediaLoaderPluginOptions
c6352f2c
C
172}
173
2adfc7ea 174type LoadedQualityData = {
9df52d66 175 qualitySwitchCallback: (resolutionId: number, type: 'video') => void
2adfc7ea
C
176 qualityData: {
177 video: {
178 id: number
179 label: string
180 selected: boolean
181 }[]
182 }
183}
184
185type ResolutionUpdateData = {
9df52d66 186 auto: boolean
2adfc7ea 187 resolutionId: number
3b6f205c 188 id?: number
2adfc7ea
C
189}
190
191type AutoResolutionUpdateData = {
192 possible: boolean
193}
194
3b6f205c 195type PlayerNetworkInfo = {
17152837
FC
196 source: 'webtorrent' | 'p2p-media-loader'
197
09209296
C
198 http: {
199 downloadSpeed: number
200 uploadSpeed: number
201 downloaded: number
202 uploaded: number
203 }
204
3b6f205c
C
205 p2p: {
206 downloadSpeed: number
207 uploadSpeed: number
208 downloaded: number
209 uploaded: number
210 numPeers: number
211 }
4e11d8f3
C
212
213 // In bytes
214 bandwidthEstimate: number
3b6f205c
C
215}
216
4572c3d0
C
217type PlaylistItemOptions = {
218 element: VideoPlaylistElement
219
e367da94 220 onClicked: () => void
4572c3d0
C
221}
222
c6352f2c 223export {
3b6f205c 224 PlayerNetworkInfo,
4572c3d0 225 PlaylistItemOptions,
a950e4c8 226 NextPreviousVideoButtonOptions,
2adfc7ea
C
227 ResolutionUpdateData,
228 AutoResolutionUpdateData,
4572c3d0 229 PlaylistPluginOptions,
6e46de09 230 VideoJSCaption,
2adfc7ea
C
231 PeerTubePluginOptions,
232 WebtorrentPluginOptions,
233 P2PMediaLoaderPluginOptions,
e367da94 234 PeerTubeResolution,
2adfc7ea 235 VideoJSPluginOptions,
83fcadac 236 LoadedQualityData,
bf1c3c78
C
237 PeerTubeLinkButtonOptions,
238 PeerTubeP2PInfoButtonOptions
c6352f2c 239}