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