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
115 type PlaylistPluginOptions = {
116 elements: VideoPlaylistElement[]
118 playlist: VideoPlaylist
120 getCurrentPosition: () => number
122 onItemClicked: (element: VideoPlaylistElement) => void
125 type NextPreviousVideoButtonOptions = {
126 type: 'next' | 'previous'
128 isDisabled: () => boolean
131 type WebtorrentPluginOptions = {
132 playerElement: HTMLVideoElement
135 videoDuration: number
137 videoFiles: VideoFile[]
139 startTime: number | string
142 type P2PMediaLoaderPluginOptions = {
143 redundancyUrlManager: RedundancyUrlManager
147 startTime: number | string
150 type VideoJSPluginOptions = {
151 playlist?: PlaylistPluginOptions
153 peertube: PeerTubePluginOptions
155 webtorrent?: WebtorrentPluginOptions
157 p2pMediaLoader?: P2PMediaLoaderPluginOptions
160 type LoadedQualityData = {
161 qualitySwitchCallback: Function,
171 type ResolutionUpdateData = {
177 type AutoResolutionUpdateData = {
181 type PlayerNetworkInfo = {
182 source: 'webtorrent' | 'p2p-media-loader'
185 downloadSpeed: number
192 downloadSpeed: number
200 type PlaylistItemOptions = {
201 element: VideoPlaylistElement
209 NextPreviousVideoButtonOptions,
210 ResolutionUpdateData,
211 AutoResolutionUpdateData,
212 PlaylistPluginOptions,
215 PeerTubePluginOptions,
216 WebtorrentPluginOptions,
217 P2PMediaLoaderPluginOptions,
218 VideoJSPluginOptions,
220 QualityLevelRepresentation,