X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fassets%2Fplayer%2Fpeertube-videojs-typings.ts;h=9616dd326e85118109aac802b5fa456c65593ea5;hb=7e37e111116e41530749b88327bc601cb39ade03;hp=d127230fa73e850e3624a175dd4708606605940d;hpb=6d8c8ea73a774c3568e6d28a4cbebcf7979d5c2a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/assets/player/peertube-videojs-typings.ts b/client/src/assets/player/peertube-videojs-typings.ts index d127230fa..9616dd326 100644 --- a/client/src/assets/player/peertube-videojs-typings.ts +++ b/client/src/assets/player/peertube-videojs-typings.ts @@ -1,22 +1,81 @@ -// FIXME: something weird with our path definition in tsconfig and typings -// @ts-ignore -import * as videojs from 'video.js' +import { PeerTubePlugin } from './peertube-plugin' +import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin' +import { P2pMediaLoaderPlugin } from './p2p-media-loader/p2p-media-loader-plugin' +import { PlayerMode } from './peertube-player-manager' +import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager' +import { VideoFile } from '@shared/models' +import videojs from 'video.js/dist/alt/video.core.js' +import { Config, Level } from 'hls.js' -import { VideoFile } from '../../../../shared/models/videos/video.model' -import { PeerTubePlugin } from './peertube-videojs-plugin' +declare module 'video.js' { + + export interface VideoJsPlayer { + srOptions_: HlsjsConfigHandlerOptions + + theaterEnabled: boolean + + // FIXME: add it to upstream typings + posterImage: { + show (): void + hide (): void + } + + handleTechSeeked_ (): void + + // Plugins -declare namespace videojs { - interface Player { peertube (): PeerTubePlugin + + webtorrent (): WebTorrentPlugin + + p2pMediaLoader (): P2pMediaLoaderPlugin + + contextmenuUI (options: any): any + + bezels (): void + + qualityLevels (): QualityLevels + + textTracks (): TextTrackList & { + on: Function + tracks_: { kind: string, mode: string, language: string }[] + } + + audioTracks (): AudioTrackList + + dock (options: { title: string, description: string }): void } } -interface VideoJSComponentInterface { - _player: videojs.Player +export interface VideoJSTechHLS extends videojs.Tech { + hlsProvider: any // FIXME: typings +} - new (player: videojs.Player, options?: any): any +export interface HlsjsConfigHandlerOptions { + hlsjsConfig?: Config & { cueHandler: any }// FIXME: typings + captionConfig?: any // FIXME: typings - registerComponent (name: string, obj: any): any + 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 } type VideoJSCaption = { @@ -30,25 +89,97 @@ type UserWatching = { authorizationHeader: string } -type PeertubePluginOptions = { - videoFiles: VideoFile[] - playerElement: HTMLVideoElement +type PeerTubePluginOptions = { + mode: PlayerMode + + autoplay: boolean videoViewUrl: string videoDuration: number - startTime: number | string - autoplay: boolean, - videoCaptions: VideoJSCaption[] userWatching?: UserWatching + subtitle?: string + + videoCaptions: VideoJSCaption[] + + stopTime: number | string } -// videojs typings don't have some method we need -const videojsUntyped = videojs as any +type WebtorrentPluginOptions = { + playerElement: HTMLVideoElement + + autoplay: boolean + videoDuration: number + + videoFiles: VideoFile[] + + startTime: number | string +} + +type P2PMediaLoaderPluginOptions = { + redundancyUrlManager: RedundancyUrlManager + type: string + src: string + + startTime: number | string +} + +type VideoJSPluginOptions = { + peertube: PeerTubePluginOptions + + webtorrent?: WebtorrentPluginOptions + + p2pMediaLoader?: P2PMediaLoaderPluginOptions +} + +type LoadedQualityData = { + qualitySwitchCallback: Function, + qualityData: { + video: { + id: number + label: string + selected: boolean + }[] + } +} + +type ResolutionUpdateData = { + auto: boolean, + resolutionId: number + id?: number +} + +type AutoResolutionUpdateData = { + possible: boolean +} + +type PlayerNetworkInfo = { + http: { + downloadSpeed: number + uploadSpeed: number + downloaded: number + uploaded: number + } + + p2p: { + downloadSpeed: number + uploadSpeed: number + downloaded: number + uploaded: number + numPeers: number + } +} export { - VideoJSComponentInterface, - PeertubePluginOptions, - videojsUntyped, + PlayerNetworkInfo, + ResolutionUpdateData, + AutoResolutionUpdateData, VideoJSCaption, - UserWatching + UserWatching, + PeerTubePluginOptions, + WebtorrentPluginOptions, + P2PMediaLoaderPluginOptions, + VideoJSPluginOptions, + LoadedQualityData, + QualityLevelRepresentation, + QualityLevels }