2020-08-04 05:42:06 -04:00
|
|
|
import { Config, Level } from 'hls.js'
|
|
|
|
import videojs from 'video.js'
|
2020-08-05 03:44:58 -04:00
|
|
|
import { VideoFile, VideoPlaylist, VideoPlaylistElement } from '@shared/models'
|
2019-01-29 02:37:25 -05:00
|
|
|
import { P2pMediaLoaderPlugin } from './p2p-media-loader/p2p-media-loader-plugin'
|
2019-08-23 04:19:44 -04:00
|
|
|
import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager'
|
2020-08-04 05:42:06 -04:00
|
|
|
import { PlayerMode } from './peertube-player-manager'
|
|
|
|
import { PeerTubePlugin } from './peertube-plugin'
|
2020-08-05 03:44:58 -04:00
|
|
|
import { PlaylistPlugin } from './playlist/playlist-plugin'
|
2020-08-04 05:42:06 -04:00
|
|
|
import { EndCardOptions } from './upnext/end-card'
|
|
|
|
import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin'
|
2018-03-30 11:40:00 -04:00
|
|
|
|
2020-01-28 11:29:50 -05:00
|
|
|
declare module 'video.js' {
|
2020-01-31 05:39:50 -05:00
|
|
|
|
2020-01-28 11:29:50 -05:00
|
|
|
export interface VideoJsPlayer {
|
2020-01-31 05:39:50 -05:00
|
|
|
srOptions_: HlsjsConfigHandlerOptions
|
|
|
|
|
2020-01-28 11:29:50 -05:00
|
|
|
theaterEnabled: boolean
|
|
|
|
|
|
|
|
// FIXME: add it to upstream typings
|
|
|
|
posterImage: {
|
|
|
|
show (): void
|
|
|
|
hide (): void
|
|
|
|
}
|
|
|
|
|
|
|
|
handleTechSeeked_ (): void
|
|
|
|
|
|
|
|
// Plugins
|
|
|
|
|
2018-03-30 11:40:00 -04:00
|
|
|
peertube (): PeerTubePlugin
|
2020-01-31 05:39:50 -05:00
|
|
|
|
2019-01-23 09:36:45 -05:00
|
|
|
webtorrent (): WebTorrentPlugin
|
2020-01-31 05:39:50 -05:00
|
|
|
|
2019-01-29 02:37:25 -05:00
|
|
|
p2pMediaLoader (): P2pMediaLoaderPlugin
|
2018-03-30 11:40:00 -04:00
|
|
|
|
2020-01-28 11:29:50 -05:00
|
|
|
contextmenuUI (options: any): any
|
|
|
|
|
|
|
|
bezels (): void
|
|
|
|
|
2020-01-31 05:39:50 -05:00
|
|
|
qualityLevels (): QualityLevels
|
2018-03-30 11:40:00 -04:00
|
|
|
|
2020-01-28 11:29:50 -05:00
|
|
|
textTracks (): TextTrackList & {
|
|
|
|
on: Function
|
2020-05-06 05:54:33 -04:00
|
|
|
tracks_: (TextTrack & { id: string, label: string, src: string })[]
|
2020-01-28 11:29:50 -05:00
|
|
|
}
|
2020-01-31 05:39:50 -05:00
|
|
|
|
2020-02-03 07:33:42 -05:00
|
|
|
dock (options: { title: string, description: string }): void
|
2020-08-04 05:42:06 -04:00
|
|
|
|
|
|
|
upnext (options: Partial<EndCardOptions>): void
|
2020-08-05 03:44:58 -04:00
|
|
|
|
|
|
|
playlist (): PlaylistPlugin
|
2020-01-28 11:29:50 -05:00
|
|
|
}
|
2018-03-30 11:40:00 -04:00
|
|
|
}
|
|
|
|
|
2020-01-31 05:39:50 -05:00
|
|
|
export interface VideoJSTechHLS extends videojs.Tech {
|
|
|
|
hlsProvider: any // FIXME: typings
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface HlsjsConfigHandlerOptions {
|
|
|
|
hlsjsConfig?: Config & { cueHandler: any }// FIXME: typings
|
|
|
|
captionConfig?: any // FIXME: typings
|
|
|
|
|
|
|
|
levelLabelHandler?: (level: Level) => string
|
|
|
|
}
|
|
|
|
|
|
|
|
type QualityLevelRepresentation = {
|
|
|
|
id: number
|
|
|
|
height: number
|
|
|
|
|
|
|
|
label?: string
|
|
|
|
width?: number
|
|
|
|
bandwidth?: number
|
|
|
|
bitrate?: number
|
|
|
|
|
|
|
|
enabled?: Function
|
|
|
|
_enabled: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
type QualityLevels = QualityLevelRepresentation[] & {
|
|
|
|
selectedIndex: number
|
|
|
|
selectedIndex_: number
|
|
|
|
|
|
|
|
addQualityLevel (representation: QualityLevelRepresentation): void
|
|
|
|
}
|
|
|
|
|
2018-07-13 12:21:19 -04:00
|
|
|
type VideoJSCaption = {
|
|
|
|
label: string
|
|
|
|
language: string
|
|
|
|
src: string
|
|
|
|
}
|
|
|
|
|
2018-10-05 05:15:06 -04:00
|
|
|
type UserWatching = {
|
|
|
|
url: string,
|
|
|
|
authorizationHeader: string
|
|
|
|
}
|
|
|
|
|
2019-01-23 09:36:45 -05:00
|
|
|
type PeerTubePluginOptions = {
|
2019-01-29 02:37:25 -05:00
|
|
|
mode: PlayerMode
|
|
|
|
|
2019-01-23 09:36:45 -05:00
|
|
|
autoplay: boolean
|
2018-03-30 11:40:00 -04:00
|
|
|
videoViewUrl: string
|
|
|
|
videoDuration: number
|
2018-10-05 05:15:06 -04:00
|
|
|
|
|
|
|
userWatching?: UserWatching
|
2019-01-23 09:36:45 -05:00
|
|
|
subtitle?: string
|
|
|
|
|
|
|
|
videoCaptions: VideoJSCaption[]
|
2019-03-07 11:06:00 -05:00
|
|
|
|
|
|
|
stopTime: number | string
|
2020-12-07 09:58:57 -05:00
|
|
|
|
|
|
|
isLive: boolean
|
2021-03-31 05:26:32 -04:00
|
|
|
|
|
|
|
videoUUID: string
|
2019-01-23 09:36:45 -05:00
|
|
|
}
|
|
|
|
|
2020-08-05 03:44:58 -04:00
|
|
|
type PlaylistPluginOptions = {
|
2021-04-21 03:46:55 -04:00
|
|
|
createComponent: boolean
|
|
|
|
|
|
|
|
elements?: VideoPlaylistElement[]
|
2020-08-05 03:44:58 -04:00
|
|
|
|
|
|
|
playlist: VideoPlaylist
|
|
|
|
|
|
|
|
getCurrentPosition: () => number
|
|
|
|
|
2021-04-21 03:46:55 -04:00
|
|
|
embedUrl: string
|
|
|
|
embedTitle: string
|
|
|
|
|
|
|
|
onItemClicked?: (element: VideoPlaylistElement) => void
|
2020-08-05 03:44:58 -04:00
|
|
|
}
|
|
|
|
|
2020-08-05 05:02:14 -04:00
|
|
|
type NextPreviousVideoButtonOptions = {
|
|
|
|
type: 'next' | 'previous'
|
|
|
|
handler: Function
|
|
|
|
isDisabled: () => boolean
|
|
|
|
}
|
|
|
|
|
2019-01-23 09:36:45 -05:00
|
|
|
type WebtorrentPluginOptions = {
|
|
|
|
playerElement: HTMLVideoElement
|
|
|
|
|
|
|
|
autoplay: boolean
|
|
|
|
videoDuration: number
|
|
|
|
|
|
|
|
videoFiles: VideoFile[]
|
2019-03-07 11:06:00 -05:00
|
|
|
|
|
|
|
startTime: number | string
|
2019-01-23 09:36:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
type P2PMediaLoaderPluginOptions = {
|
2019-08-23 04:19:44 -04:00
|
|
|
redundancyUrlManager: RedundancyUrlManager
|
2019-01-23 09:36:45 -05:00
|
|
|
type: string
|
|
|
|
src: string
|
2019-03-07 11:06:00 -05:00
|
|
|
|
|
|
|
startTime: number | string
|
2019-01-23 09:36:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
type VideoJSPluginOptions = {
|
2020-08-05 03:44:58 -04:00
|
|
|
playlist?: PlaylistPluginOptions
|
|
|
|
|
2019-01-23 09:36:45 -05:00
|
|
|
peertube: PeerTubePluginOptions
|
|
|
|
|
|
|
|
webtorrent?: WebtorrentPluginOptions
|
|
|
|
|
|
|
|
p2pMediaLoader?: P2PMediaLoaderPluginOptions
|
2018-03-30 11:40:00 -04:00
|
|
|
}
|
|
|
|
|
2019-01-23 09:36:45 -05:00
|
|
|
type LoadedQualityData = {
|
|
|
|
qualitySwitchCallback: Function,
|
|
|
|
qualityData: {
|
|
|
|
video: {
|
|
|
|
id: number
|
|
|
|
label: string
|
|
|
|
selected: boolean
|
|
|
|
}[]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResolutionUpdateData = {
|
|
|
|
auto: boolean,
|
|
|
|
resolutionId: number
|
2019-01-24 04:16:30 -05:00
|
|
|
id?: number
|
2019-01-23 09:36:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
type AutoResolutionUpdateData = {
|
|
|
|
possible: boolean
|
|
|
|
}
|
|
|
|
|
2019-01-24 04:16:30 -05:00
|
|
|
type PlayerNetworkInfo = {
|
2020-12-04 10:30:01 -05:00
|
|
|
source: 'webtorrent' | 'p2p-media-loader'
|
|
|
|
|
2019-01-29 02:37:25 -05:00
|
|
|
http: {
|
|
|
|
downloadSpeed: number
|
|
|
|
uploadSpeed: number
|
|
|
|
downloaded: number
|
|
|
|
uploaded: number
|
|
|
|
}
|
|
|
|
|
2019-01-24 04:16:30 -05:00
|
|
|
p2p: {
|
|
|
|
downloadSpeed: number
|
|
|
|
uploadSpeed: number
|
|
|
|
downloaded: number
|
|
|
|
uploaded: number
|
|
|
|
numPeers: number
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-05 03:44:58 -04:00
|
|
|
type PlaylistItemOptions = {
|
|
|
|
element: VideoPlaylistElement
|
|
|
|
|
|
|
|
onClicked: Function
|
|
|
|
}
|
|
|
|
|
2018-03-30 11:40:00 -04:00
|
|
|
export {
|
2019-01-24 04:16:30 -05:00
|
|
|
PlayerNetworkInfo,
|
2020-08-05 03:44:58 -04:00
|
|
|
PlaylistItemOptions,
|
2020-08-05 05:02:14 -04:00
|
|
|
NextPreviousVideoButtonOptions,
|
2019-01-23 09:36:45 -05:00
|
|
|
ResolutionUpdateData,
|
|
|
|
AutoResolutionUpdateData,
|
2020-08-05 03:44:58 -04:00
|
|
|
PlaylistPluginOptions,
|
2018-10-05 05:15:06 -04:00
|
|
|
VideoJSCaption,
|
2019-01-23 09:36:45 -05:00
|
|
|
UserWatching,
|
|
|
|
PeerTubePluginOptions,
|
|
|
|
WebtorrentPluginOptions,
|
|
|
|
P2PMediaLoaderPluginOptions,
|
|
|
|
VideoJSPluginOptions,
|
2020-01-31 05:39:50 -05:00
|
|
|
LoadedQualityData,
|
|
|
|
QualityLevelRepresentation,
|
|
|
|
QualityLevels
|
2018-03-30 11:40:00 -04:00
|
|
|
}
|