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