]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/assets/player/peertube-videojs-typings.ts
Merge branch 'develop' into pr/1285
[github/Chocobozzz/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-plugin'
7 import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin'
8 import { P2pMediaLoaderPlugin } from './p2p-media-loader/p2p-media-loader-plugin'
9 import { PlayerMode } from './peertube-player-manager'
10
11 declare namespace videojs {
12 interface Player {
13 peertube (): PeerTubePlugin
14 webtorrent (): WebTorrentPlugin
15 p2pMediaLoader (): P2pMediaLoaderPlugin
16 }
17 }
18
19 interface VideoJSComponentInterface {
20 _player: videojs.Player
21
22 new (player: videojs.Player, options?: any): any
23
24 registerComponent (name: string, obj: any): any
25 }
26
27 type VideoJSCaption = {
28 label: string
29 language: string
30 src: string
31 }
32
33 type UserWatching = {
34 url: string,
35 authorizationHeader: string
36 }
37
38 type PeerTubePluginOptions = {
39 mode: PlayerMode
40
41 autoplay: boolean
42 videoViewUrl: string
43 videoDuration: number
44 startTime: number | string
45
46 userWatching?: UserWatching
47 subtitle?: string
48
49 videoCaptions: VideoJSCaption[]
50 }
51
52 type WebtorrentPluginOptions = {
53 playerElement: HTMLVideoElement
54
55 autoplay: boolean
56 videoDuration: number
57
58 videoFiles: VideoFile[]
59 }
60
61 type P2PMediaLoaderPluginOptions = {
62 redundancyBaseUrls: string[]
63 type: string
64 src: string
65 }
66
67 type VideoJSPluginOptions = {
68 peertube: PeerTubePluginOptions
69
70 webtorrent?: WebtorrentPluginOptions
71
72 p2pMediaLoader?: P2PMediaLoaderPluginOptions
73 }
74
75 // videojs typings don't have some method we need
76 const videojsUntyped = videojs as any
77
78 type LoadedQualityData = {
79 qualitySwitchCallback: Function,
80 qualityData: {
81 video: {
82 id: number
83 label: string
84 selected: boolean
85 }[]
86 }
87 }
88
89 type ResolutionUpdateData = {
90 auto: boolean,
91 resolutionId: number
92 id?: number
93 }
94
95 type AutoResolutionUpdateData = {
96 possible: boolean
97 }
98
99 type PlayerNetworkInfo = {
100 http: {
101 downloadSpeed: number
102 uploadSpeed: number
103 downloaded: number
104 uploaded: number
105 }
106
107 p2p: {
108 downloadSpeed: number
109 uploadSpeed: number
110 downloaded: number
111 uploaded: number
112 numPeers: number
113 }
114 }
115
116 export {
117 PlayerNetworkInfo,
118 ResolutionUpdateData,
119 AutoResolutionUpdateData,
120 VideoJSComponentInterface,
121 videojsUntyped,
122 VideoJSCaption,
123 UserWatching,
124 PeerTubePluginOptions,
125 WebtorrentPluginOptions,
126 P2PMediaLoaderPluginOptions,
127 VideoJSPluginOptions,
128 LoadedQualityData
129 }