1
0
Fork 0
peertube/client/src/assets/player/peertube-videojs-typings.ts

136 lines
2.6 KiB
TypeScript
Raw Normal View History

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'
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'
import { VideoFile } from '@shared/models'
2018-06-07 10:50:33 -04:00
declare namespace videojs {
interface Player {
peertube (): PeerTubePlugin
webtorrent (): WebTorrentPlugin
2019-01-29 02:37:25 -05:00
p2pMediaLoader (): P2pMediaLoaderPlugin
}
}
interface VideoJSComponentInterface {
_player: videojs.Player
new (player: videojs.Player, options?: any): any
registerComponent (name: string, obj: any): any
}
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
}
type PeerTubePluginOptions = {
2019-01-29 02:37:25 -05:00
mode: PlayerMode
autoplay: boolean
videoViewUrl: string
videoDuration: number
2018-10-05 05:15:06 -04:00
userWatching?: UserWatching
subtitle?: string
videoCaptions: VideoJSCaption[]
2019-03-07 11:06:00 -05:00
stopTime: number | string
}
type WebtorrentPluginOptions = {
playerElement: HTMLVideoElement
autoplay: boolean
videoDuration: number
videoFiles: VideoFile[]
2019-03-07 11:06:00 -05:00
startTime: number | string
}
type P2PMediaLoaderPluginOptions = {
2019-08-23 04:19:44 -04:00
redundancyUrlManager: RedundancyUrlManager
type: string
src: string
2019-03-07 11:06:00 -05: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 04:16:30 -05:00
id?: number
}
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
}
}
export {
2019-01-24 04:16:30 -05:00
PlayerNetworkInfo,
ResolutionUpdateData,
AutoResolutionUpdateData,
VideoJSComponentInterface,
2018-07-13 12:21:19 -04:00
videojsUntyped,
2018-10-05 05:15:06 -04:00
VideoJSCaption,
UserWatching,
PeerTubePluginOptions,
WebtorrentPluginOptions,
P2PMediaLoaderPluginOptions,
VideoJSPluginOptions,
LoadedQualityData
}