1 import { HlsConfig, Level } from 'hls.js'
2 import videojs from 'video.js'
3 import { Engine } from '@peertube/p2p-media-loader-hlsjs'
4 import { VideoFile, VideoPlaylist, VideoPlaylistElement } from '@shared/models'
5 import { PeerTubeDockPluginOptions } from '../shared/dock/peertube-dock-plugin'
6 import { Html5Hlsjs } from '../shared/p2p-media-loader/hls-plugin'
7 import { P2pMediaLoaderPlugin } from '../shared/p2p-media-loader/p2p-media-loader-plugin'
8 import { RedundancyUrlManager } from '../shared/p2p-media-loader/redundancy-url-manager'
9 import { PeerTubePlugin } from '../shared/peertube/peertube-plugin'
10 import { PlaylistPlugin } from '../shared/playlist/playlist-plugin'
11 import { PeerTubeResolutionsPlugin } from '../shared/resolutions/peertube-resolutions-plugin'
12 import { StatsCardOptions } from '../shared/stats/stats-card'
13 import { StatsForNerdsPlugin } from '../shared/stats/stats-plugin'
14 import { EndCardOptions } from '../shared/upnext/end-card'
15 import { WebTorrentPlugin } from '../shared/webtorrent/webtorrent-plugin'
16 import { PlayerMode } from './manager-options'
18 declare module 'video.js' {
20 export interface VideoJsPlayer {
21 srOptions_: HlsjsConfigHandlerOptions
23 theaterEnabled: boolean
25 // FIXME: add it to upstream typings
31 handleTechSeeked_ (): void
35 peertube (): PeerTubePlugin
37 webtorrent (): WebTorrentPlugin
39 p2pMediaLoader (): P2pMediaLoaderPlugin
41 peertubeResolutions (): PeerTubeResolutionsPlugin
43 contextmenuUI (options: any): any
46 peertubeMobile (): void
47 peerTubeHotkeysPlugin (): void
49 stats (options?: StatsCardOptions): StatsForNerdsPlugin
51 textTracks (): TextTrackList & {
52 tracks_: (TextTrack & { id: string, label: string, src: string })[]
55 peertubeDock (options: PeerTubeDockPluginOptions): void
57 upnext (options: Partial<EndCardOptions>): void
59 playlist (): PlaylistPlugin
63 export interface VideoJSTechHLS extends videojs.Tech {
64 hlsProvider: Html5Hlsjs
67 export interface HlsjsConfigHandlerOptions {
68 hlsjsConfig?: HlsConfig
70 levelLabelHandler?: (level: Level) => string
73 type PeerTubeResolution = {
82 selectCallback: () => void
85 type VideoJSCaption = {
91 type PeerTubePluginOptions = {
94 autoplay: videojs.Autoplay
98 authorizationHeader?: () => string
102 videoCaptions: VideoJSCaption[]
104 startTime: number | string
105 stopTime: number | string
112 type MetricsPluginOptions = {
118 type PlaylistPluginOptions = {
119 elements: VideoPlaylistElement[]
121 playlist: VideoPlaylist
123 getCurrentPosition: () => number
125 onItemClicked: (element: VideoPlaylistElement) => void
128 type NextPreviousVideoButtonOptions = {
129 type: 'next' | 'previous'
131 isDisabled: () => boolean
134 type PeerTubeLinkButtonOptions = {
139 type PeerTubeP2PInfoButtonOptions = {
143 type WebtorrentPluginOptions = {
144 playerElement: HTMLVideoElement
146 autoplay: videojs.Autoplay
147 videoDuration: number
149 videoFiles: VideoFile[]
151 startTime: number | string
153 playerRefusedP2P: boolean
155 requiresAuth: boolean
156 videoFileToken: () => string
158 buildWebSeedUrls: (file: VideoFile) => string[]
161 type P2PMediaLoaderPluginOptions = {
162 redundancyUrlManager: RedundancyUrlManager
166 startTime: number | string
168 loader: P2PMediaLoader
170 requiresAuth: boolean
171 videoFileToken: () => string
174 export type P2PMediaLoader = {
178 type VideoJSPluginOptions = {
179 playlist?: PlaylistPluginOptions
181 peertube: PeerTubePluginOptions
182 metrics: MetricsPluginOptions
184 webtorrent?: WebtorrentPluginOptions
186 p2pMediaLoader?: P2PMediaLoaderPluginOptions
189 type LoadedQualityData = {
190 qualitySwitchCallback: (resolutionId: number, type: 'video') => void
200 type ResolutionUpdateData = {
206 type AutoResolutionUpdateData = {
210 type PlayerNetworkInfo = {
211 source: 'webtorrent' | 'p2p-media-loader'
214 downloadSpeed: number
219 downloadSpeed: number
227 bandwidthEstimate: number
230 type PlaylistItemOptions = {
231 element: VideoPlaylistElement
233 onClicked: () => void
239 NextPreviousVideoButtonOptions,
240 ResolutionUpdateData,
241 AutoResolutionUpdateData,
242 PlaylistPluginOptions,
243 MetricsPluginOptions,
245 PeerTubePluginOptions,
246 WebtorrentPluginOptions,
247 P2PMediaLoaderPluginOptions,
249 VideoJSPluginOptions,
251 PeerTubeLinkButtonOptions,
252 PeerTubeP2PInfoButtonOptions