2 /* eslint-disable @typescript-eslint/ban-types */
4 import { HlsConfig, Level } from 'hls.js'
5 import videojs from 'video.js'
6 import { VideoFile, VideoPlaylist, VideoPlaylistElement } from '@shared/models'
7 import { P2pMediaLoaderPlugin } from './p2p-media-loader/p2p-media-loader-plugin'
8 import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager'
9 import { PlayerMode } from './peertube-player-manager'
10 import { PeerTubePlugin } from './peertube-plugin'
11 import { PlaylistPlugin } from './playlist/playlist-plugin'
12 import { EndCardOptions } from './upnext/end-card'
13 import { StatsCardOptions } from './stats/stats-card'
14 import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin'
15 import { StatsForNerdsPlugin } from './stats/stats-plugin'
17 declare module 'video.js' {
19 export interface VideoJsPlayer {
20 srOptions_: HlsjsConfigHandlerOptions
22 theaterEnabled: boolean
24 // FIXME: add it to upstream typings
30 handleTechSeeked_ (): void
34 peertube (): PeerTubePlugin
36 webtorrent (): WebTorrentPlugin
38 p2pMediaLoader (): P2pMediaLoaderPlugin
40 contextmenuUI (options: any): any
44 stats (options?: StatsCardOptions): StatsForNerdsPlugin
46 qualityLevels (): QualityLevels
48 textTracks (): TextTrackList & {
50 tracks_: (TextTrack & { id: string, label: string, src: string })[]
53 dock (options: { title: string, description: string }): void
55 upnext (options: Partial<EndCardOptions>): void
57 playlist (): PlaylistPlugin
61 export interface VideoJSTechHLS extends videojs.Tech {
62 hlsProvider: any // FIXME: typings
65 export interface HlsjsConfigHandlerOptions {
66 hlsjsConfig?: HlsConfig & { cueHandler: any }// FIXME: typings
67 captionConfig?: any // FIXME: typings
69 levelLabelHandler?: (level: Level) => string
72 type QualityLevelRepresentation = {
85 type QualityLevels = QualityLevelRepresentation[] & {
87 selectedIndex_: number
89 addQualityLevel (representation: QualityLevelRepresentation): void
92 type VideoJSCaption = {
100 authorizationHeader: string
103 type PeerTubePluginOptions = {
108 videoDuration: number
110 userWatching?: UserWatching
113 videoCaptions: VideoJSCaption[]
115 stopTime: number | string
122 type PlaylistPluginOptions = {
123 elements: VideoPlaylistElement[]
125 playlist: VideoPlaylist
127 getCurrentPosition: () => number
129 onItemClicked: (element: VideoPlaylistElement) => void
132 type NextPreviousVideoButtonOptions = {
133 type: 'next' | 'previous'
135 isDisabled: () => boolean
138 type PeerTubeLinkButtonOptions = {
142 type WebtorrentPluginOptions = {
143 playerElement: HTMLVideoElement
146 videoDuration: number
148 videoFiles: VideoFile[]
150 startTime: number | string
153 type P2PMediaLoaderPluginOptions = {
154 redundancyUrlManager: RedundancyUrlManager
158 startTime: number | string
161 type VideoJSPluginOptions = {
162 playlist?: PlaylistPluginOptions
164 peertube: PeerTubePluginOptions
166 webtorrent?: WebtorrentPluginOptions
168 p2pMediaLoader?: P2PMediaLoaderPluginOptions
171 type LoadedQualityData = {
172 qualitySwitchCallback: (resolutionId: number, type: 'video') => void
182 type ResolutionUpdateData = {
188 type AutoResolutionUpdateData = {
192 type PlayerNetworkInfo = {
193 source: 'webtorrent' | 'p2p-media-loader'
196 downloadSpeed: number
203 downloadSpeed: number
211 bandwidthEstimate: number
214 type PlaylistItemOptions = {
215 element: VideoPlaylistElement
223 NextPreviousVideoButtonOptions,
224 ResolutionUpdateData,
225 AutoResolutionUpdateData,
226 PlaylistPluginOptions,
229 PeerTubePluginOptions,
230 WebtorrentPluginOptions,
231 P2PMediaLoaderPluginOptions,
232 VideoJSPluginOptions,
234 QualityLevelRepresentation,
235 PeerTubeLinkButtonOptions,