1 import { HlsConfig, 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 { PeerTubeResolutionsPlugin } from './peertube-resolutions-plugin'
9 import { PlaylistPlugin } from './playlist/playlist-plugin'
10 import { StatsCardOptions } from './stats/stats-card'
11 import { StatsForNerdsPlugin } from './stats/stats-plugin'
12 import { EndCardOptions } from './upnext/end-card'
13 import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin'
15 declare module 'video.js' {
17 export interface VideoJsPlayer {
18 srOptions_: HlsjsConfigHandlerOptions
20 theaterEnabled: boolean
22 // FIXME: add it to upstream typings
28 handleTechSeeked_ (): void
32 peertube (): PeerTubePlugin
34 webtorrent (): WebTorrentPlugin
36 p2pMediaLoader (): P2pMediaLoaderPlugin
38 peertubeResolutions (): PeerTubeResolutionsPlugin
40 contextmenuUI (options: any): any
44 stats (options?: StatsCardOptions): StatsForNerdsPlugin
46 textTracks (): TextTrackList & {
47 tracks_: (TextTrack & { id: string, label: string, src: string })[]
50 dock (options: { title: string, description: string }): void
52 upnext (options: Partial<EndCardOptions>): void
54 playlist (): PlaylistPlugin
58 export interface VideoJSTechHLS extends videojs.Tech {
59 hlsProvider: any // FIXME: typings
62 export interface HlsjsConfigHandlerOptions {
63 hlsjsConfig?: HlsConfig & { cueHandler: any }// FIXME: typings
64 captionConfig?: any // FIXME: typings
66 levelLabelHandler?: (level: Level) => string
69 type PeerTubeResolution = {
78 selectCallback: () => void
81 type VideoJSCaption = {
89 authorizationHeader: string
92 type PeerTubePluginOptions = {
99 userWatching?: UserWatching
102 videoCaptions: VideoJSCaption[]
104 stopTime: number | string
111 type PlaylistPluginOptions = {
112 elements: VideoPlaylistElement[]
114 playlist: VideoPlaylist
116 getCurrentPosition: () => number
118 onItemClicked: (element: VideoPlaylistElement) => void
121 type NextPreviousVideoButtonOptions = {
122 type: 'next' | 'previous'
124 isDisabled: () => boolean
127 type PeerTubeLinkButtonOptions = {
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: (resolutionId: number, type: 'video') => void
171 type ResolutionUpdateData = {
177 type AutoResolutionUpdateData = {
181 type PlayerNetworkInfo = {
182 source: 'webtorrent' | 'p2p-media-loader'
185 downloadSpeed: number
192 downloadSpeed: number
200 bandwidthEstimate: number
203 type PlaylistItemOptions = {
204 element: VideoPlaylistElement
206 onClicked: () => void
212 NextPreviousVideoButtonOptions,
213 ResolutionUpdateData,
214 AutoResolutionUpdateData,
215 PlaylistPluginOptions,
218 PeerTubePluginOptions,
219 WebtorrentPluginOptions,
220 P2PMediaLoaderPluginOptions,
222 VideoJSPluginOptions,
224 PeerTubeLinkButtonOptions