]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/assets/player/types/peertube-videojs-typings.ts
Support reinjecting token in private m3u8 playlist
[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
59a643aa 94 autoplay: videojs.Autoplay
c6352f2c 95 videoDuration: number
6e46de09 96
384ba8b7 97 videoViewUrl: string
3545e72c 98 authorizationHeader?: () => string
384ba8b7 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
fd3c2e87
C
112type MetricsPluginOptions = {
113 mode: PlayerMode
114 metricsUrl: string
115 videoUUID: string
116}
117
4572c3d0 118type PlaylistPluginOptions = {
3e0e8d4a 119 elements: VideoPlaylistElement[]
4572c3d0
C
120
121 playlist: VideoPlaylist
122
123 getCurrentPosition: () => number
124
3e0e8d4a 125 onItemClicked: (element: VideoPlaylistElement) => void
4572c3d0
C
126}
127
a950e4c8
C
128type NextPreviousVideoButtonOptions = {
129 type: 'next' | 'previous'
e367da94 130 handler: () => void
a950e4c8
C
131 isDisabled: () => boolean
132}
133
9162fdd3
C
134type PeerTubeLinkButtonOptions = {
135 shortUUID: string
bd2b51be 136 instanceName: string
9162fdd3
C
137}
138
bf1c3c78
C
139type PeerTubeP2PInfoButtonOptions = {
140 p2pEnabled: boolean
141}
142
2adfc7ea
C
143type WebtorrentPluginOptions = {
144 playerElement: HTMLVideoElement
145
59a643aa 146 autoplay: videojs.Autoplay
2adfc7ea
C
147 videoDuration: number
148
149 videoFiles: VideoFile[]
f0a39880
C
150
151 startTime: number | string
a9bfa85d
C
152
153 playerRefusedP2P: boolean
3545e72c
C
154
155 requiresAuth: boolean
156 videoFileToken: () => string
157
158 buildWebSeedUrls: (file: VideoFile) => string[]
2adfc7ea
C
159}
160
161type P2PMediaLoaderPluginOptions = {
da332417 162 redundancyUrlManager: RedundancyUrlManager
2adfc7ea
C
163 type: string
164 src: string
f0a39880
C
165
166 startTime: number | string
9597920e
C
167
168 loader: P2PMediaLoader
326f3692
C
169
170 requiresAuth: boolean
71e3e879 171 videoFileToken: () => string
9597920e
C
172}
173
174export type P2PMediaLoader = {
175 getEngine(): Engine
2adfc7ea
C
176}
177
178type VideoJSPluginOptions = {
4572c3d0
C
179 playlist?: PlaylistPluginOptions
180
2adfc7ea 181 peertube: PeerTubePluginOptions
fd3c2e87 182 metrics: MetricsPluginOptions
2adfc7ea
C
183
184 webtorrent?: WebtorrentPluginOptions
185
186 p2pMediaLoader?: P2PMediaLoaderPluginOptions
c6352f2c
C
187}
188
2adfc7ea 189type LoadedQualityData = {
9df52d66 190 qualitySwitchCallback: (resolutionId: number, type: 'video') => void
2adfc7ea
C
191 qualityData: {
192 video: {
193 id: number
194 label: string
195 selected: boolean
196 }[]
197 }
198}
199
200type ResolutionUpdateData = {
9df52d66 201 auto: boolean
2adfc7ea 202 resolutionId: number
3b6f205c 203 id?: number
2adfc7ea
C
204}
205
206type AutoResolutionUpdateData = {
207 possible: boolean
208}
209
3b6f205c 210type PlayerNetworkInfo = {
17152837
FC
211 source: 'webtorrent' | 'p2p-media-loader'
212
09209296
C
213 http: {
214 downloadSpeed: number
09209296 215 downloaded: number
09209296
C
216 }
217
3b6f205c
C
218 p2p: {
219 downloadSpeed: number
220 uploadSpeed: number
221 downloaded: number
222 uploaded: number
223 numPeers: number
224 }
4e11d8f3
C
225
226 // In bytes
227 bandwidthEstimate: number
3b6f205c
C
228}
229
4572c3d0
C
230type PlaylistItemOptions = {
231 element: VideoPlaylistElement
232
e367da94 233 onClicked: () => void
4572c3d0
C
234}
235
c6352f2c 236export {
3b6f205c 237 PlayerNetworkInfo,
4572c3d0 238 PlaylistItemOptions,
a950e4c8 239 NextPreviousVideoButtonOptions,
2adfc7ea
C
240 ResolutionUpdateData,
241 AutoResolutionUpdateData,
4572c3d0 242 PlaylistPluginOptions,
fd3c2e87 243 MetricsPluginOptions,
6e46de09 244 VideoJSCaption,
2adfc7ea
C
245 PeerTubePluginOptions,
246 WebtorrentPluginOptions,
247 P2PMediaLoaderPluginOptions,
e367da94 248 PeerTubeResolution,
2adfc7ea 249 VideoJSPluginOptions,
83fcadac 250 LoadedQualityData,
bf1c3c78
C
251 PeerTubeLinkButtonOptions,
252 PeerTubeP2PInfoButtonOptions
c6352f2c 253}