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