PeerTube/client/src/assets/player/peertube-videojs-typings.ts

226 lines
4.4 KiB
TypeScript
Raw Normal View History

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'
2020-08-05 09:44:58 +02:00
import { VideoFile, VideoPlaylist, VideoPlaylistElement } from '@shared/models'
2021-10-22 16:18:00 +02:00
import { Html5Hlsjs } from './p2p-media-loader/hls-plugin'
2019-01-29 08:37:25 +01:00
import { P2pMediaLoaderPlugin } from './p2p-media-loader/p2p-media-loader-plugin'
2019-08-23 10:19:44 +02:00
import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager'
2020-08-04 11:42:06 +02:00
import { PlayerMode } from './peertube-player-manager'
import { PeerTubePlugin } from './peertube-plugin'
2021-09-06 16:08:59 +02:00
import { PeerTubeResolutionsPlugin } from './peertube-resolutions-plugin'
2020-08-05 09:44:58 +02:00
import { PlaylistPlugin } from './playlist/playlist-plugin'
2021-04-12 10:26:30 +02:00
import { StatsCardOptions } from './stats/stats-card'
2021-04-27 15:50:29 +02:00
import { StatsForNerdsPlugin } from './stats/stats-plugin'
2021-09-06 16:08:59 +02:00
import { EndCardOptions } from './upnext/end-card'
import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin'
2020-01-28 17:29:50 +01:00
declare module 'video.js' {
2020-01-28 17:29:50 +01:00
export interface VideoJsPlayer {
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
peertube (): PeerTubePlugin
webtorrent (): WebTorrentPlugin
2019-01-29 08:37:25 +01:00
p2pMediaLoader (): P2pMediaLoaderPlugin
2021-09-06 16:08:59 +02:00
peertubeResolutions (): PeerTubeResolutionsPlugin
2020-01-28 17:29:50 +01:00
contextmenuUI (options: any): any
bezels (): void
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-02-03 13:33:42 +01:00
dock (options: { title: string, description: string }): 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
}
}
export interface VideoJSTechHLS extends videojs.Tech {
2021-10-22 16:18:00 +02:00
hlsProvider: Html5Hlsjs
}
export interface HlsjsConfigHandlerOptions {
2021-10-22 16:18:00 +02:00
hlsjsConfig?: HlsConfig
levelLabelHandler?: (level: Level) => string
}
2021-09-06 16:08:59 +02:00
type PeerTubeResolution = {
id: number
2021-09-06 16:08:59 +02:00
height?: number
label?: string
width?: number
bitrate?: number
2021-09-06 16:08:59 +02:00
selected: boolean
selectCallback: () => void
}
2018-07-13 18:21:19 +02:00
type VideoJSCaption = {
label: string
language: string
src: string
}
2018-10-05 11:15:06 +02:00
type UserWatching = {
2021-08-17 14:42:53 +02:00
url: string
2018-10-05 11:15:06 +02:00
authorizationHeader: string
}
type PeerTubePluginOptions = {
2019-01-29 08:37:25 +01:00
mode: PlayerMode
autoplay: boolean
videoViewUrl: string
videoDuration: number
2018-10-05 11:15:06 +02:00
userWatching?: UserWatching
subtitle?: string
videoCaptions: VideoJSCaption[]
2019-03-07 17:06:00 +01:00
stopTime: number | string
2020-12-07 15:58:57 +01:00
isLive: boolean
videoUUID: string
}
2020-08-05 09:44:58 +02:00
type PlaylistPluginOptions = {
elements: VideoPlaylistElement[]
2020-08-05 09:44:58 +02:00
playlist: VideoPlaylist
getCurrentPosition: () => number
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
}
type WebtorrentPluginOptions = {
playerElement: HTMLVideoElement
autoplay: boolean
videoDuration: number
videoFiles: VideoFile[]
2019-03-07 17:06:00 +01:00
startTime: number | string
}
type P2PMediaLoaderPluginOptions = {
2019-08-23 10:19:44 +02:00
redundancyUrlManager: RedundancyUrlManager
type: string
src: string
2019-03-07 17:06:00 +01:00
startTime: number | string
}
type VideoJSPluginOptions = {
2020-08-05 09:44:58 +02:00
playlist?: PlaylistPluginOptions
peertube: PeerTubePluginOptions
webtorrent?: WebtorrentPluginOptions
p2pMediaLoader?: P2PMediaLoaderPluginOptions
}
type LoadedQualityData = {
2021-08-17 14:42:53 +02:00
qualitySwitchCallback: (resolutionId: number, type: 'video') => void
qualityData: {
video: {
id: number
label: string
selected: boolean
}[]
}
}
type ResolutionUpdateData = {
2021-08-17 14:42:53 +02:00
auto: boolean
resolutionId: number
2019-01-24 10:16:30 +01:00
id?: number
}
type AutoResolutionUpdateData = {
possible: boolean
}
2019-01-24 10:16:30 +01:00
type PlayerNetworkInfo = {
source: 'webtorrent' | 'p2p-media-loader'
2019-01-29 08:37:25 +01:00
http: {
downloadSpeed: number
uploadSpeed: number
downloaded: number
uploaded: 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
}
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,
ResolutionUpdateData,
AutoResolutionUpdateData,
2020-08-05 09:44:58 +02:00
PlaylistPluginOptions,
2018-10-05 11:15:06 +02:00
VideoJSCaption,
UserWatching,
PeerTubePluginOptions,
WebtorrentPluginOptions,
P2PMediaLoaderPluginOptions,
2021-09-06 16:08:59 +02:00
PeerTubeResolution,
VideoJSPluginOptions,
LoadedQualityData,
2021-09-06 16:08:59 +02:00
PeerTubeLinkButtonOptions
}