]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/assets/player/types/peertube-videojs-typings.ts
Add live autostart/messages in embed
[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
130}
131
bf1c3c78
C
132type PeerTubeP2PInfoButtonOptions = {
133 p2pEnabled: boolean
134}
135
2adfc7ea
C
136type WebtorrentPluginOptions = {
137 playerElement: HTMLVideoElement
138
139 autoplay: boolean
140 videoDuration: number
141
142 videoFiles: VideoFile[]
f0a39880
C
143
144 startTime: number | string
a9bfa85d
C
145
146 playerRefusedP2P: boolean
2adfc7ea
C
147}
148
149type P2PMediaLoaderPluginOptions = {
da332417 150 redundancyUrlManager: RedundancyUrlManager
2adfc7ea
C
151 type: string
152 src: string
f0a39880
C
153
154 startTime: number | string
9597920e
C
155
156 loader: P2PMediaLoader
157}
158
159export type P2PMediaLoader = {
160 getEngine(): Engine
2adfc7ea
C
161}
162
163type VideoJSPluginOptions = {
4572c3d0
C
164 playlist?: PlaylistPluginOptions
165
2adfc7ea
C
166 peertube: PeerTubePluginOptions
167
168 webtorrent?: WebtorrentPluginOptions
169
170 p2pMediaLoader?: P2PMediaLoaderPluginOptions
c6352f2c
C
171}
172
2adfc7ea 173type LoadedQualityData = {
9df52d66 174 qualitySwitchCallback: (resolutionId: number, type: 'video') => void
2adfc7ea
C
175 qualityData: {
176 video: {
177 id: number
178 label: string
179 selected: boolean
180 }[]
181 }
182}
183
184type ResolutionUpdateData = {
9df52d66 185 auto: boolean
2adfc7ea 186 resolutionId: number
3b6f205c 187 id?: number
2adfc7ea
C
188}
189
190type AutoResolutionUpdateData = {
191 possible: boolean
192}
193
3b6f205c 194type PlayerNetworkInfo = {
17152837
FC
195 source: 'webtorrent' | 'p2p-media-loader'
196
09209296
C
197 http: {
198 downloadSpeed: number
199 uploadSpeed: number
200 downloaded: number
201 uploaded: number
202 }
203
3b6f205c
C
204 p2p: {
205 downloadSpeed: number
206 uploadSpeed: number
207 downloaded: number
208 uploaded: number
209 numPeers: number
210 }
4e11d8f3
C
211
212 // In bytes
213 bandwidthEstimate: number
3b6f205c
C
214}
215
4572c3d0
C
216type PlaylistItemOptions = {
217 element: VideoPlaylistElement
218
e367da94 219 onClicked: () => void
4572c3d0
C
220}
221
c6352f2c 222export {
3b6f205c 223 PlayerNetworkInfo,
4572c3d0 224 PlaylistItemOptions,
a950e4c8 225 NextPreviousVideoButtonOptions,
2adfc7ea
C
226 ResolutionUpdateData,
227 AutoResolutionUpdateData,
4572c3d0 228 PlaylistPluginOptions,
6e46de09 229 VideoJSCaption,
2adfc7ea
C
230 PeerTubePluginOptions,
231 WebtorrentPluginOptions,
232 P2PMediaLoaderPluginOptions,
e367da94 233 PeerTubeResolution,
2adfc7ea 234 VideoJSPluginOptions,
83fcadac 235 LoadedQualityData,
bf1c3c78
C
236 PeerTubeLinkButtonOptions,
237 PeerTubeP2PInfoButtonOptions
c6352f2c 238}