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