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'
12 declare module 'video.js' {
14 export interface VideoJsPlayer {
15 srOptions_: HlsjsConfigHandlerOptions
17 theaterEnabled: boolean
19 // FIXME: add it to upstream typings
25 handleTechSeeked_ (): void
29 peertube (): PeerTubePlugin
31 webtorrent (): WebTorrentPlugin
33 p2pMediaLoader (): P2pMediaLoaderPlugin
35 contextmenuUI (options: any): any
39 qualityLevels (): QualityLevels
41 textTracks (): TextTrackList & {
43 tracks_: (TextTrack & { id: string, label: string, src: string })[]
46 dock (options: { title: string, description: string }): void
48 upnext (options: Partial<EndCardOptions>): void
50 playlist (): PlaylistPlugin
54 export interface VideoJSTechHLS extends videojs.Tech {
55 hlsProvider: any // FIXME: typings
58 export interface HlsjsConfigHandlerOptions {
59 hlsjsConfig?: Config & { cueHandler: any }// FIXME: typings
60 captionConfig?: any // FIXME: typings
62 levelLabelHandler?: (level: Level) => string
65 type QualityLevelRepresentation = {
78 type QualityLevels = QualityLevelRepresentation[] & {
80 selectedIndex_: number
82 addQualityLevel (representation: QualityLevelRepresentation): void
85 type VideoJSCaption = {
93 authorizationHeader: string
96 type PeerTubePluginOptions = {
101 videoDuration: number
103 userWatching?: UserWatching
106 videoCaptions: VideoJSCaption[]
108 stopTime: number | string
111 type PlaylistPluginOptions = {
112 elements: VideoPlaylistElement[]
114 playlist: VideoPlaylist
116 getCurrentPosition: () => number
118 onItemClicked: (element: VideoPlaylistElement) => void
121 type WebtorrentPluginOptions = {
122 playerElement: HTMLVideoElement
125 videoDuration: number
127 videoFiles: VideoFile[]
129 startTime: number | string
132 type P2PMediaLoaderPluginOptions = {
133 redundancyUrlManager: RedundancyUrlManager
137 startTime: number | string
140 type VideoJSPluginOptions = {
141 playlist?: PlaylistPluginOptions
143 peertube: PeerTubePluginOptions
145 webtorrent?: WebtorrentPluginOptions
147 p2pMediaLoader?: P2PMediaLoaderPluginOptions
150 type LoadedQualityData = {
151 qualitySwitchCallback: Function,
161 type ResolutionUpdateData = {
167 type AutoResolutionUpdateData = {
171 type PlayerNetworkInfo = {
173 downloadSpeed: number
180 downloadSpeed: number
188 type PlaylistItemOptions = {
189 element: VideoPlaylistElement
197 ResolutionUpdateData,
198 AutoResolutionUpdateData,
199 PlaylistPluginOptions,
202 PeerTubePluginOptions,
203 WebtorrentPluginOptions,
204 P2PMediaLoaderPluginOptions,
205 VideoJSPluginOptions,
207 QualityLevelRepresentation,