1 import { HlsConfig, Level } from 'hls.js'
2 import videojs from 'video.js'
3 import { VideoFile, VideoPlaylist, VideoPlaylistElement } from '@shared/models'
4 import { Html5Hlsjs } from './p2p-media-loader/hls-plugin'
5 import { P2pMediaLoaderPlugin } from './p2p-media-loader/p2p-media-loader-plugin'
6 import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager'
7 import { PlayerMode } from './peertube-player-manager'
8 import { PeerTubePlugin } from './peertube-plugin'
9 import { PeerTubeResolutionsPlugin } from './peertube-resolutions-plugin'
10 import { PlaylistPlugin } from './playlist/playlist-plugin'
11 import { StatsCardOptions } from './stats/stats-card'
12 import { StatsForNerdsPlugin } from './stats/stats-plugin'
13 import { EndCardOptions } from './upnext/end-card'
14 import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin'
16 declare module 'video.js' {
18 export interface VideoJsPlayer {
19 srOptions_: HlsjsConfigHandlerOptions
21 theaterEnabled: boolean
23 // FIXME: add it to upstream typings
29 handleTechSeeked_ (): void
33 peertube (): PeerTubePlugin
35 webtorrent (): WebTorrentPlugin
37 p2pMediaLoader (): P2pMediaLoaderPlugin
39 peertubeResolutions (): PeerTubeResolutionsPlugin
41 contextmenuUI (options: any): any
45 peertubeMobile (): void
47 stats (options?: StatsCardOptions): StatsForNerdsPlugin
49 textTracks (): TextTrackList & {
50 tracks_: (TextTrack & { id: string, label: string, src: string })[]
53 dock (options: { title: string, description: string }): void
55 upnext (options: Partial<EndCardOptions>): void
57 playlist (): PlaylistPlugin
61 export interface VideoJSTechHLS extends videojs.Tech {
62 hlsProvider: Html5Hlsjs
65 export interface HlsjsConfigHandlerOptions {
66 hlsjsConfig?: HlsConfig
68 levelLabelHandler?: (level: Level) => string
71 type PeerTubeResolution = {
80 selectCallback: () => void
83 type VideoJSCaption = {
91 authorizationHeader: string
94 type PeerTubePluginOptions = {
101 userWatching?: UserWatching
104 videoCaptions: VideoJSCaption[]
106 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 PeerTubeLinkButtonOptions = {
133 type PeerTubeP2PInfoButtonOptions = {
137 type WebtorrentPluginOptions = {
138 playerElement: HTMLVideoElement
141 videoDuration: number
143 videoFiles: VideoFile[]
145 startTime: number | string
147 playerRefusedP2P: boolean
150 type P2PMediaLoaderPluginOptions = {
151 redundancyUrlManager: RedundancyUrlManager
155 startTime: number | string
158 type VideoJSPluginOptions = {
159 playlist?: PlaylistPluginOptions
161 peertube: PeerTubePluginOptions
163 webtorrent?: WebtorrentPluginOptions
165 p2pMediaLoader?: P2PMediaLoaderPluginOptions
168 type LoadedQualityData = {
169 qualitySwitchCallback: (resolutionId: number, type: 'video') => void
179 type ResolutionUpdateData = {
185 type AutoResolutionUpdateData = {
189 type PlayerNetworkInfo = {
190 source: 'webtorrent' | 'p2p-media-loader'
193 downloadSpeed: number
200 downloadSpeed: number
208 bandwidthEstimate: number
211 type PlaylistItemOptions = {
212 element: VideoPlaylistElement
214 onClicked: () => void
220 NextPreviousVideoButtonOptions,
221 ResolutionUpdateData,
222 AutoResolutionUpdateData,
223 PlaylistPluginOptions,
226 PeerTubePluginOptions,
227 WebtorrentPluginOptions,
228 P2PMediaLoaderPluginOptions,
230 VideoJSPluginOptions,
232 PeerTubeLinkButtonOptions,
233 PeerTubeP2PInfoButtonOptions