2021-08-03 11:51:49 +02:00
|
|
|
import { HlsConfig, Level } from 'hls.js'
|
2020-08-04 11:42:06 +02:00
|
|
|
import videojs from 'video.js'
|
2022-03-14 11:16:54 +01:00
|
|
|
import { Engine } from '@peertube/p2p-media-loader-hlsjs'
|
2020-08-05 09:44:58 +02:00
|
|
|
import { VideoFile, VideoPlaylist, VideoPlaylistElement } from '@shared/models'
|
2022-03-14 14:28:20 +01:00
|
|
|
import { PeerTubeDockPluginOptions } from '../shared/dock/peertube-dock-plugin'
|
|
|
|
import { Html5Hlsjs } from '../shared/p2p-media-loader/hls-plugin'
|
|
|
|
import { P2pMediaLoaderPlugin } from '../shared/p2p-media-loader/p2p-media-loader-plugin'
|
|
|
|
import { RedundancyUrlManager } from '../shared/p2p-media-loader/redundancy-url-manager'
|
|
|
|
import { PeerTubePlugin } from '../shared/peertube/peertube-plugin'
|
|
|
|
import { PlaylistPlugin } from '../shared/playlist/playlist-plugin'
|
|
|
|
import { PeerTubeResolutionsPlugin } from '../shared/resolutions/peertube-resolutions-plugin'
|
|
|
|
import { StatsCardOptions } from '../shared/stats/stats-card'
|
|
|
|
import { StatsForNerdsPlugin } from '../shared/stats/stats-plugin'
|
|
|
|
import { EndCardOptions } from '../shared/upnext/end-card'
|
|
|
|
import { WebTorrentPlugin } from '../shared/webtorrent/webtorrent-plugin'
|
|
|
|
import { PlayerMode } from './manager-options'
|
2018-03-30 17:40:00 +02:00
|
|
|
|
2020-01-28 17:29:50 +01:00
|
|
|
declare module 'video.js' {
|
2020-01-31 11:39:50 +01:00
|
|
|
|
2020-01-28 17:29:50 +01:00
|
|
|
export interface VideoJsPlayer {
|
2020-01-31 11:39:50 +01:00
|
|
|
srOptions_: HlsjsConfigHandlerOptions
|
|
|
|
|
2020-01-28 17:29:50 +01:00
|
|
|
theaterEnabled: boolean
|
|
|
|
|
|
|
|
// FIXME: add it to upstream typings
|
|
|
|
posterImage: {
|
|
|
|
show (): void
|
|
|
|
hide (): void
|
|
|
|
}
|
|
|
|
|
|
|
|
handleTechSeeked_ (): void
|
|
|
|
|
|
|
|
// Plugins
|
|
|
|
|
2018-03-30 17:40:00 +02:00
|
|
|
peertube (): PeerTubePlugin
|
2020-01-31 11:39:50 +01:00
|
|
|
|
2019-01-23 15:36:45 +01:00
|
|
|
webtorrent (): WebTorrentPlugin
|
2020-01-31 11:39:50 +01:00
|
|
|
|
2019-01-29 08:37:25 +01:00
|
|
|
p2pMediaLoader (): P2pMediaLoaderPlugin
|
2018-03-30 17:40:00 +02:00
|
|
|
|
2021-09-06 16:08:59 +02:00
|
|
|
peertubeResolutions (): PeerTubeResolutionsPlugin
|
|
|
|
|
2020-01-28 17:29:50 +01:00
|
|
|
contextmenuUI (options: any): any
|
|
|
|
|
|
|
|
bezels (): void
|
2022-01-11 11:26:35 +01:00
|
|
|
peertubeMobile (): void
|
2022-01-13 11:14:28 +01:00
|
|
|
peerTubeHotkeysPlugin (): void
|
2022-01-11 11:26:35 +01:00
|
|
|
|
2021-04-27 15:50:29 +02:00
|
|
|
stats (options?: StatsCardOptions): StatsForNerdsPlugin
|
2021-04-12 10:26:30 +02:00
|
|
|
|
2020-01-28 17:29:50 +01:00
|
|
|
textTracks (): TextTrackList & {
|
2020-05-06 11:54:33 +02:00
|
|
|
tracks_: (TextTrack & { id: string, label: string, src: string })[]
|
2020-01-28 17:29:50 +01:00
|
|
|
}
|
2020-01-31 11:39:50 +01:00
|
|
|
|
2022-03-08 16:26:30 +01:00
|
|
|
peertubeDock (options: PeerTubeDockPluginOptions): void
|
2020-08-04 11:42:06 +02:00
|
|
|
|
|
|
|
upnext (options: Partial<EndCardOptions>): void
|
2020-08-05 09:44:58 +02:00
|
|
|
|
|
|
|
playlist (): PlaylistPlugin
|
2020-01-28 17:29:50 +01:00
|
|
|
}
|
2018-03-30 17:40:00 +02:00
|
|
|
}
|
|
|
|
|
2020-01-31 11:39:50 +01:00
|
|
|
export interface VideoJSTechHLS extends videojs.Tech {
|
2021-10-22 16:18:00 +02:00
|
|
|
hlsProvider: Html5Hlsjs
|
2020-01-31 11:39:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface HlsjsConfigHandlerOptions {
|
2021-10-22 16:18:00 +02:00
|
|
|
hlsjsConfig?: HlsConfig
|
2020-01-31 11:39:50 +01:00
|
|
|
|
|
|
|
levelLabelHandler?: (level: Level) => string
|
|
|
|
}
|
|
|
|
|
2021-09-06 16:08:59 +02:00
|
|
|
type PeerTubeResolution = {
|
2020-01-31 11:39:50 +01:00
|
|
|
id: number
|
|
|
|
|
2021-09-06 16:08:59 +02:00
|
|
|
height?: number
|
2020-01-31 11:39:50 +01:00
|
|
|
label?: string
|
|
|
|
width?: number
|
|
|
|
bitrate?: number
|
|
|
|
|
2021-09-06 16:08:59 +02:00
|
|
|
selected: boolean
|
|
|
|
selectCallback: () => void
|
2020-01-31 11:39:50 +01:00
|
|
|
}
|
|
|
|
|
2018-07-13 18:21:19 +02:00
|
|
|
type VideoJSCaption = {
|
|
|
|
label: string
|
|
|
|
language: string
|
|
|
|
src: string
|
|
|
|
}
|
|
|
|
|
2019-01-23 15:36:45 +01:00
|
|
|
type PeerTubePluginOptions = {
|
2019-01-29 08:37:25 +01:00
|
|
|
mode: PlayerMode
|
|
|
|
|
2019-01-23 15:36:45 +01:00
|
|
|
autoplay: boolean
|
2018-03-30 17:40:00 +02:00
|
|
|
videoDuration: number
|
2018-10-05 11:15:06 +02:00
|
|
|
|
2022-04-05 14:03:52 +02:00
|
|
|
videoViewUrl: string
|
2022-10-12 16:09:02 +02:00
|
|
|
authorizationHeader?: () => string
|
2022-04-05 14:03:52 +02:00
|
|
|
|
2019-01-23 15:36:45 +01:00
|
|
|
subtitle?: string
|
|
|
|
|
|
|
|
videoCaptions: VideoJSCaption[]
|
2019-03-07 17:06:00 +01:00
|
|
|
|
2022-04-05 14:03:52 +02:00
|
|
|
startTime: number | string
|
2019-03-07 17:06:00 +01:00
|
|
|
stopTime: number | string
|
2020-12-07 15:58:57 +01:00
|
|
|
|
|
|
|
isLive: boolean
|
2021-03-31 11:26:32 +02:00
|
|
|
|
|
|
|
videoUUID: string
|
2019-01-23 15:36:45 +01:00
|
|
|
}
|
|
|
|
|
2022-08-12 16:41:29 +02:00
|
|
|
type MetricsPluginOptions = {
|
|
|
|
mode: PlayerMode
|
|
|
|
metricsUrl: string
|
|
|
|
videoUUID: string
|
|
|
|
}
|
|
|
|
|
2020-08-05 09:44:58 +02:00
|
|
|
type PlaylistPluginOptions = {
|
2021-04-21 15:28:12 +02:00
|
|
|
elements: VideoPlaylistElement[]
|
2020-08-05 09:44:58 +02:00
|
|
|
|
|
|
|
playlist: VideoPlaylist
|
|
|
|
|
|
|
|
getCurrentPosition: () => number
|
|
|
|
|
2021-04-21 15:28:12 +02:00
|
|
|
onItemClicked: (element: VideoPlaylistElement) => void
|
2020-08-05 09:44:58 +02:00
|
|
|
}
|
|
|
|
|
2020-08-05 11:02:14 +02:00
|
|
|
type NextPreviousVideoButtonOptions = {
|
|
|
|
type: 'next' | 'previous'
|
2021-09-06 16:08:59 +02:00
|
|
|
handler: () => void
|
2020-08-05 11:02:14 +02:00
|
|
|
isDisabled: () => boolean
|
|
|
|
}
|
|
|
|
|
2021-07-26 14:12:39 +02:00
|
|
|
type PeerTubeLinkButtonOptions = {
|
|
|
|
shortUUID: string
|
2022-06-28 14:04:03 +02:00
|
|
|
instanceName: string
|
2021-07-26 14:12:39 +02:00
|
|
|
}
|
|
|
|
|
2021-12-15 16:18:05 +01:00
|
|
|
type PeerTubeP2PInfoButtonOptions = {
|
|
|
|
p2pEnabled: boolean
|
|
|
|
}
|
|
|
|
|
2019-01-23 15:36:45 +01:00
|
|
|
type WebtorrentPluginOptions = {
|
|
|
|
playerElement: HTMLVideoElement
|
|
|
|
|
|
|
|
autoplay: boolean
|
|
|
|
videoDuration: number
|
|
|
|
|
|
|
|
videoFiles: VideoFile[]
|
2019-03-07 17:06:00 +01:00
|
|
|
|
|
|
|
startTime: number | string
|
2021-12-15 15:58:10 +01:00
|
|
|
|
|
|
|
playerRefusedP2P: boolean
|
2022-10-12 16:09:02 +02:00
|
|
|
|
|
|
|
requiresAuth: boolean
|
|
|
|
videoFileToken: () => string
|
|
|
|
|
|
|
|
buildWebSeedUrls: (file: VideoFile) => string[]
|
2019-01-23 15:36:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type P2PMediaLoaderPluginOptions = {
|
2019-08-23 10:19:44 +02:00
|
|
|
redundancyUrlManager: RedundancyUrlManager
|
2019-01-23 15:36:45 +01:00
|
|
|
type: string
|
|
|
|
src: string
|
2019-03-07 17:06:00 +01:00
|
|
|
|
|
|
|
startTime: number | string
|
2022-03-14 11:16:54 +01:00
|
|
|
|
|
|
|
loader: P2PMediaLoader
|
|
|
|
}
|
|
|
|
|
|
|
|
export type P2PMediaLoader = {
|
|
|
|
getEngine(): Engine
|
2019-01-23 15:36:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type VideoJSPluginOptions = {
|
2020-08-05 09:44:58 +02:00
|
|
|
playlist?: PlaylistPluginOptions
|
|
|
|
|
2019-01-23 15:36:45 +01:00
|
|
|
peertube: PeerTubePluginOptions
|
2022-08-12 16:41:29 +02:00
|
|
|
metrics: MetricsPluginOptions
|
2019-01-23 15:36:45 +01:00
|
|
|
|
|
|
|
webtorrent?: WebtorrentPluginOptions
|
|
|
|
|
|
|
|
p2pMediaLoader?: P2PMediaLoaderPluginOptions
|
2018-03-30 17:40:00 +02:00
|
|
|
}
|
|
|
|
|
2019-01-23 15:36:45 +01:00
|
|
|
type LoadedQualityData = {
|
2021-08-17 14:42:53 +02:00
|
|
|
qualitySwitchCallback: (resolutionId: number, type: 'video') => void
|
2019-01-23 15:36:45 +01:00
|
|
|
qualityData: {
|
|
|
|
video: {
|
|
|
|
id: number
|
|
|
|
label: string
|
|
|
|
selected: boolean
|
|
|
|
}[]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResolutionUpdateData = {
|
2021-08-17 14:42:53 +02:00
|
|
|
auto: boolean
|
2019-01-23 15:36:45 +01:00
|
|
|
resolutionId: number
|
2019-01-24 10:16:30 +01:00
|
|
|
id?: number
|
2019-01-23 15:36:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type AutoResolutionUpdateData = {
|
|
|
|
possible: boolean
|
|
|
|
}
|
|
|
|
|
2019-01-24 10:16:30 +01:00
|
|
|
type PlayerNetworkInfo = {
|
2020-12-04 16:30:01 +01:00
|
|
|
source: 'webtorrent' | 'p2p-media-loader'
|
|
|
|
|
2019-01-29 08:37:25 +01:00
|
|
|
http: {
|
|
|
|
downloadSpeed: number
|
|
|
|
downloaded: number
|
|
|
|
}
|
|
|
|
|
2019-01-24 10:16:30 +01:00
|
|
|
p2p: {
|
|
|
|
downloadSpeed: number
|
|
|
|
uploadSpeed: number
|
|
|
|
downloaded: number
|
|
|
|
uploaded: number
|
|
|
|
numPeers: number
|
|
|
|
}
|
2021-04-27 15:50:29 +02:00
|
|
|
|
|
|
|
// In bytes
|
|
|
|
bandwidthEstimate: number
|
2019-01-24 10:16:30 +01:00
|
|
|
}
|
|
|
|
|
2020-08-05 09:44:58 +02:00
|
|
|
type PlaylistItemOptions = {
|
|
|
|
element: VideoPlaylistElement
|
|
|
|
|
2021-09-06 16:08:59 +02:00
|
|
|
onClicked: () => void
|
2020-08-05 09:44:58 +02:00
|
|
|
}
|
|
|
|
|
2018-03-30 17:40:00 +02:00
|
|
|
export {
|
2019-01-24 10:16:30 +01:00
|
|
|
PlayerNetworkInfo,
|
2020-08-05 09:44:58 +02:00
|
|
|
PlaylistItemOptions,
|
2020-08-05 11:02:14 +02:00
|
|
|
NextPreviousVideoButtonOptions,
|
2019-01-23 15:36:45 +01:00
|
|
|
ResolutionUpdateData,
|
|
|
|
AutoResolutionUpdateData,
|
2020-08-05 09:44:58 +02:00
|
|
|
PlaylistPluginOptions,
|
2022-08-12 16:41:29 +02:00
|
|
|
MetricsPluginOptions,
|
2018-10-05 11:15:06 +02:00
|
|
|
VideoJSCaption,
|
2019-01-23 15:36:45 +01:00
|
|
|
PeerTubePluginOptions,
|
|
|
|
WebtorrentPluginOptions,
|
|
|
|
P2PMediaLoaderPluginOptions,
|
2021-09-06 16:08:59 +02:00
|
|
|
PeerTubeResolution,
|
2019-01-23 15:36:45 +01:00
|
|
|
VideoJSPluginOptions,
|
2020-01-31 11:39:50 +01:00
|
|
|
LoadedQualityData,
|
2021-12-15 16:18:05 +01:00
|
|
|
PeerTubeLinkButtonOptions,
|
|
|
|
PeerTubeP2PInfoButtonOptions
|
2018-03-30 17:40:00 +02:00
|
|
|
}
|