2018-10-18 14:35:31 +02:00
|
|
|
// FIXME: something weird with our path definition in tsconfig and typings
|
|
|
|
// @ts-ignore
|
|
|
|
import * as videojs from 'video.js'
|
|
|
|
|
2019-01-23 15:36:45 +01:00
|
|
|
import { PeerTubePlugin } from './peertube-plugin'
|
2019-01-29 08:37:25 +01:00
|
|
|
import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin'
|
|
|
|
import { P2pMediaLoaderPlugin } from './p2p-media-loader/p2p-media-loader-plugin'
|
|
|
|
import { PlayerMode } from './peertube-player-manager'
|
2019-08-23 10:19:44 +02:00
|
|
|
import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager'
|
2019-11-15 15:06:03 +01:00
|
|
|
import { VideoFile } from '@shared/models'
|
2018-03-30 17:40:00 +02:00
|
|
|
|
2018-06-07 16:50:33 +02:00
|
|
|
declare namespace videojs {
|
2018-03-30 17:40:00 +02:00
|
|
|
interface Player {
|
|
|
|
peertube (): PeerTubePlugin
|
2019-01-23 15:36:45 +01:00
|
|
|
webtorrent (): WebTorrentPlugin
|
2019-01-29 08:37:25 +01:00
|
|
|
p2pMediaLoader (): P2pMediaLoaderPlugin
|
2018-03-30 17:40:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
interface VideoJSComponentInterface {
|
|
|
|
_player: videojs.Player
|
|
|
|
|
2018-10-18 09:08:59 +02:00
|
|
|
new (player: videojs.Player, options?: any): any
|
2018-03-30 17:40:00 +02:00
|
|
|
|
2018-10-18 09:08:59 +02:00
|
|
|
registerComponent (name: string, obj: any): any
|
2018-03-30 17:40:00 +02:00
|
|
|
}
|
|
|
|
|
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 = {
|
|
|
|
url: string,
|
|
|
|
authorizationHeader: 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
|
|
|
videoViewUrl: string
|
|
|
|
videoDuration: number
|
2018-10-05 11:15:06 +02:00
|
|
|
|
|
|
|
userWatching?: UserWatching
|
2019-01-23 15:36:45 +01:00
|
|
|
subtitle?: string
|
|
|
|
|
|
|
|
videoCaptions: VideoJSCaption[]
|
2019-03-07 17:06:00 +01:00
|
|
|
|
|
|
|
stopTime: number | string
|
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
|
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
|
2019-01-23 15:36:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type VideoJSPluginOptions = {
|
|
|
|
peertube: PeerTubePluginOptions
|
|
|
|
|
|
|
|
webtorrent?: WebtorrentPluginOptions
|
|
|
|
|
|
|
|
p2pMediaLoader?: P2PMediaLoaderPluginOptions
|
2018-03-30 17:40:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// videojs typings don't have some method we need
|
|
|
|
const videojsUntyped = videojs as any
|
|
|
|
|
2019-01-23 15:36:45 +01:00
|
|
|
type LoadedQualityData = {
|
|
|
|
qualitySwitchCallback: Function,
|
|
|
|
qualityData: {
|
|
|
|
video: {
|
|
|
|
id: number
|
|
|
|
label: string
|
|
|
|
selected: boolean
|
|
|
|
}[]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type ResolutionUpdateData = {
|
|
|
|
auto: boolean,
|
|
|
|
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 = {
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-30 17:40:00 +02:00
|
|
|
export {
|
2019-01-24 10:16:30 +01:00
|
|
|
PlayerNetworkInfo,
|
2019-01-23 15:36:45 +01:00
|
|
|
ResolutionUpdateData,
|
|
|
|
AutoResolutionUpdateData,
|
2018-03-30 17:40:00 +02:00
|
|
|
VideoJSComponentInterface,
|
2018-07-13 18:21:19 +02:00
|
|
|
videojsUntyped,
|
2018-10-05 11:15:06 +02:00
|
|
|
VideoJSCaption,
|
2019-01-23 15:36:45 +01:00
|
|
|
UserWatching,
|
|
|
|
PeerTubePluginOptions,
|
|
|
|
WebtorrentPluginOptions,
|
|
|
|
P2PMediaLoaderPluginOptions,
|
|
|
|
VideoJSPluginOptions,
|
|
|
|
LoadedQualityData
|
2018-03-30 17:40:00 +02:00
|
|
|
}
|