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'
13 declare module 'video.js' {
15 export interface VideoJsPlayer {
16 srOptions_: HlsjsConfigHandlerOptions
18 theaterEnabled: boolean
20 // FIXME: add it to upstream typings
26 handleTechSeeked_ (): void
30 peertube (): PeerTubePlugin
32 webtorrent (): WebTorrentPlugin
34 p2pMediaLoader (): P2pMediaLoaderPlugin
36 contextmenuUI (options: any): any
40 stats (options?: Partial<StatsCardOptions>): any
42 qualityLevels (): QualityLevels
44 textTracks (): TextTrackList & {
46 tracks_: (TextTrack & { id: string, label: string, src: string })[]
49 dock (options: { title: string, description: string }): void
51 upnext (options: Partial<EndCardOptions>): void
53 playlist (): PlaylistPlugin
57 export interface VideoJSTechHLS extends videojs.Tech {
58 hlsProvider: any // FIXME: typings
61 export interface HlsjsConfigHandlerOptions {
62 hlsjsConfig?: Config & { cueHandler: any }// FIXME: typings
63 captionConfig?: any // FIXME: typings
65 levelLabelHandler?: (level: Level) => string
68 type QualityLevelRepresentation = {
81 type QualityLevels = QualityLevelRepresentation[] & {
83 selectedIndex_: number
85 addQualityLevel (representation: QualityLevelRepresentation): void
88 type VideoJSCaption = {
96 authorizationHeader: string
99 type PeerTubePluginOptions = {
104 videoDuration: number
106 userWatching?: UserWatching
109 videoCaptions: VideoJSCaption[]
111 stopTime: number | string
118 type PlaylistPluginOptions = {
119 elements: VideoPlaylistElement[]
121 playlist: VideoPlaylist
123 getCurrentPosition: () => number
125 onItemClicked: (element: VideoPlaylistElement) => void
128 type NextPreviousVideoButtonOptions = {
129 type: 'next' | 'previous'
131 isDisabled: () => boolean
134 type WebtorrentPluginOptions = {
135 playerElement: HTMLVideoElement
138 videoDuration: number
140 videoFiles: VideoFile[]
142 startTime: number | string
145 type P2PMediaLoaderPluginOptions = {
146 redundancyUrlManager: RedundancyUrlManager
150 startTime: number | string
153 type VideoJSPluginOptions = {
154 playlist?: PlaylistPluginOptions
156 peertube: PeerTubePluginOptions
158 webtorrent?: WebtorrentPluginOptions
160 p2pMediaLoader?: P2PMediaLoaderPluginOptions
163 type LoadedQualityData = {
164 qualitySwitchCallback: Function,
174 type ResolutionUpdateData = {
180 type AutoResolutionUpdateData = {
184 type PlayerNetworkInfo = {
185 source: 'webtorrent' | 'p2p-media-loader'
188 downloadSpeed: number
195 downloadSpeed: number
203 type PlaylistItemOptions = {
204 element: VideoPlaylistElement
212 NextPreviousVideoButtonOptions,
213 ResolutionUpdateData,
214 AutoResolutionUpdateData,
215 PlaylistPluginOptions,
218 PeerTubePluginOptions,
219 WebtorrentPluginOptions,
220 P2PMediaLoaderPluginOptions,
221 VideoJSPluginOptions,
223 QualityLevelRepresentation,