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
113 type PlaylistPluginOptions = {
114 elements: VideoPlaylistElement[]
116 playlist: VideoPlaylist
118 getCurrentPosition: () => number
120 onItemClicked: (element: VideoPlaylistElement) => void
123 type NextPreviousVideoButtonOptions = {
124 type: 'next' | 'previous'
126 isDisabled: () => boolean
129 type WebtorrentPluginOptions = {
130 playerElement: HTMLVideoElement
133 videoDuration: number
135 videoFiles: VideoFile[]
137 startTime: number | string
140 type P2PMediaLoaderPluginOptions = {
141 redundancyUrlManager: RedundancyUrlManager
145 startTime: number | string
148 type VideoJSPluginOptions = {
149 playlist?: PlaylistPluginOptions
151 peertube: PeerTubePluginOptions
153 webtorrent?: WebtorrentPluginOptions
155 p2pMediaLoader?: P2PMediaLoaderPluginOptions
158 type LoadedQualityData = {
159 qualitySwitchCallback: Function,
169 type ResolutionUpdateData = {
175 type AutoResolutionUpdateData = {
179 type PlayerNetworkInfo = {
180 source: 'webtorrent' | 'p2p-media-loader'
183 downloadSpeed: number
190 downloadSpeed: number
198 type PlaylistItemOptions = {
199 element: VideoPlaylistElement
207 NextPreviousVideoButtonOptions,
208 ResolutionUpdateData,
209 AutoResolutionUpdateData,
210 PlaylistPluginOptions,
213 PeerTubePluginOptions,
214 WebtorrentPluginOptions,
215 P2PMediaLoaderPluginOptions,
216 VideoJSPluginOptions,
218 QualityLevelRepresentation,