Merge branch 'release/v1.2.0'
[oweals/peertube.git] / client / src / assets / player / peertube-videojs-typings.ts
1 // FIXME: something weird with our path definition in tsconfig and typings
2 // @ts-ignore
3 import * as videojs from 'video.js'
4
5 import { VideoFile } from '../../../../shared/models/videos/video.model'
6 import { PeerTubePlugin } from './peertube-videojs-plugin'
7
8 declare namespace videojs {
9   interface Player {
10     peertube (): PeerTubePlugin
11   }
12 }
13
14 interface VideoJSComponentInterface {
15   _player: videojs.Player
16
17   new (player: videojs.Player, options?: any): any
18
19   registerComponent (name: string, obj: any): any
20 }
21
22 type VideoJSCaption = {
23   label: string
24   language: string
25   src: string
26 }
27
28 type UserWatching = {
29   url: string,
30   authorizationHeader: string
31 }
32
33 type PeertubePluginOptions = {
34   videoFiles: VideoFile[]
35   playerElement: HTMLVideoElement
36   videoViewUrl: string
37   videoDuration: number
38   startTime: number | string
39   autoplay: boolean,
40   videoCaptions: VideoJSCaption[]
41
42   subtitle?: string
43   userWatching?: UserWatching
44 }
45
46 // videojs typings don't have some method we need
47 const videojsUntyped = videojs as any
48
49 export {
50   VideoJSComponentInterface,
51   PeertubePluginOptions,
52   videojsUntyped,
53   VideoJSCaption,
54   UserWatching
55 }