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 WebtorrentPluginOptions = {
136 playerElement: HTMLVideoElement
139 videoDuration: number
141 videoFiles: VideoFile[]
143 startTime: number | string
146 type P2PMediaLoaderPluginOptions = {
147 redundancyUrlManager: RedundancyUrlManager
151 startTime: number | string
154 type VideoJSPluginOptions = {
155 playlist?: PlaylistPluginOptions
157 peertube: PeerTubePluginOptions
159 webtorrent?: WebtorrentPluginOptions
161 p2pMediaLoader?: P2PMediaLoaderPluginOptions
164 type LoadedQualityData = {
165 qualitySwitchCallback: Function,
175 type ResolutionUpdateData = {
181 type AutoResolutionUpdateData = {
185 type PlayerNetworkInfo = {
186 source: 'webtorrent' | 'p2p-media-loader'
189 downloadSpeed: number
196 downloadSpeed: number
204 bandwidthEstimate: number
207 type PlaylistItemOptions = {
208 element: VideoPlaylistElement
216 NextPreviousVideoButtonOptions,
217 ResolutionUpdateData,
218 AutoResolutionUpdateData,
219 PlaylistPluginOptions,
222 PeerTubePluginOptions,
223 WebtorrentPluginOptions,
224 P2PMediaLoaderPluginOptions,
225 VideoJSPluginOptions,
227 QualityLevelRepresentation,