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

136 lines
2.6 KiB
TypeScript
Raw Normal View History

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'
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'
import { VideoFile } from '@shared/models'
2018-06-07 16:50:33 +02:00
declare namespace videojs {
interface Player {
peertube (): PeerTubePlugin
webtorrent (): WebTorrentPlugin
2019-01-29 08:37:25 +01:00
p2pMediaLoader (): P2pMediaLoaderPlugin
}
}
interface VideoJSComponentInterface {
_player: videojs.Player
new (player: videojs.Player, options?: any): any
registerComponent (name: string, obj: any): any
}
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
}
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
}
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 = {
peertube: PeerTubePluginOptions
webtorrent?: WebtorrentPluginOptions
p2pMediaLoader?: P2PMediaLoaderPluginOptions
}
// videojs typings don't have some method we need
const videojsUntyped = videojs as any
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
}
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
}
}
export {
2019-01-24 10:16:30 +01:00
PlayerNetworkInfo,
ResolutionUpdateData,
AutoResolutionUpdateData,
VideoJSComponentInterface,
2018-07-13 18:21:19 +02:00
videojsUntyped,
2018-10-05 11:15:06 +02:00
VideoJSCaption,
UserWatching,
PeerTubePluginOptions,
WebtorrentPluginOptions,
P2PMediaLoaderPluginOptions,
VideoJSPluginOptions,
LoadedQualityData
}