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 { StatsCardOptions } from './stats/stats-card'
11 import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin'
12 import { StatsForNerdsPlugin } from './stats/stats-plugin'
14 declare module 'video.js' {
16 export interface VideoJsPlayer {
17 srOptions_: HlsjsConfigHandlerOptions
19 theaterEnabled: boolean
21 // FIXME: add it to upstream typings
27 handleTechSeeked_ (): void
31 peertube (): PeerTubePlugin
33 webtorrent (): WebTorrentPlugin
35 p2pMediaLoader (): P2pMediaLoaderPlugin
37 contextmenuUI (options: any): any
41 stats (options?: StatsCardOptions): StatsForNerdsPlugin
43 qualityLevels (): QualityLevels
45 textTracks (): TextTrackList & {
47 tracks_: (TextTrack & { id: string, label: string, src: string })[]
50 dock (options: { title: string, description: string }): void
52 upnext (options: Partial<EndCardOptions>): void
54 playlist (): PlaylistPlugin
58 export interface VideoJSTechHLS extends videojs.Tech {
59 hlsProvider: any // FIXME: typings
62 export interface HlsjsConfigHandlerOptions {
63 hlsjsConfig?: Config & { cueHandler: any }// FIXME: typings
64 captionConfig?: any // FIXME: typings
66 levelLabelHandler?: (level: Level) => string
69 type QualityLevelRepresentation = {
82 type QualityLevels = QualityLevelRepresentation[] & {
84 selectedIndex_: number
86 addQualityLevel (representation: QualityLevelRepresentation): void
89 type VideoJSCaption = {
97 authorizationHeader: string
100 type PeerTubePluginOptions = {
105 videoDuration: number
107 userWatching?: UserWatching
110 videoCaptions: VideoJSCaption[]
112 stopTime: number | string
119 type PlaylistPluginOptions = {
120 elements: VideoPlaylistElement[]
122 playlist: VideoPlaylist
124 getCurrentPosition: () => number
126 onItemClicked: (element: VideoPlaylistElement) => void
129 type NextPreviousVideoButtonOptions = {
130 type: 'next' | 'previous'
132 isDisabled: () => boolean
135 type PeerTubeLinkButtonOptions = {
139 type WebtorrentPluginOptions = {
140 playerElement: HTMLVideoElement
143 videoDuration: number
145 videoFiles: VideoFile[]
147 startTime: number | string
150 type P2PMediaLoaderPluginOptions = {
151 redundancyUrlManager: RedundancyUrlManager
155 startTime: number | string
158 type VideoJSPluginOptions = {
159 playlist?: PlaylistPluginOptions
161 peertube: PeerTubePluginOptions
163 webtorrent?: WebtorrentPluginOptions
165 p2pMediaLoader?: P2PMediaLoaderPluginOptions
168 type LoadedQualityData = {
169 qualitySwitchCallback: Function,
179 type ResolutionUpdateData = {
185 type AutoResolutionUpdateData = {
189 type PlayerNetworkInfo = {
190 source: 'webtorrent' | 'p2p-media-loader'
193 downloadSpeed: number
200 downloadSpeed: number
208 bandwidthEstimate: number
211 type PlaylistItemOptions = {
212 element: VideoPlaylistElement
220 NextPreviousVideoButtonOptions,
221 ResolutionUpdateData,
222 AutoResolutionUpdateData,
223 PlaylistPluginOptions,
226 PeerTubePluginOptions,
227 WebtorrentPluginOptions,
228 P2PMediaLoaderPluginOptions,
229 VideoJSPluginOptions,
231 QualityLevelRepresentation,
232 PeerTubeLinkButtonOptions,