]>
Commit | Line | Data |
---|---|---|
1 | import { Config, Level } from 'hls.js' | |
2 | import videojs from 'video.js' | |
3 | import { VideoFile } from '@shared/models' | |
4 | import { P2pMediaLoaderPlugin } from './p2p-media-loader/p2p-media-loader-plugin' | |
5 | import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager' | |
6 | import { PlayerMode } from './peertube-player-manager' | |
7 | import { PeerTubePlugin } from './peertube-plugin' | |
8 | import { EndCardOptions } from './upnext/end-card' | |
9 | import { WebTorrentPlugin } from './webtorrent/webtorrent-plugin' | |
10 | ||
11 | declare module 'video.js' { | |
12 | ||
13 | export interface VideoJsPlayer { | |
14 | srOptions_: HlsjsConfigHandlerOptions | |
15 | ||
16 | theaterEnabled: boolean | |
17 | ||
18 | // FIXME: add it to upstream typings | |
19 | posterImage: { | |
20 | show (): void | |
21 | hide (): void | |
22 | } | |
23 | ||
24 | handleTechSeeked_ (): void | |
25 | ||
26 | // Plugins | |
27 | ||
28 | peertube (): PeerTubePlugin | |
29 | ||
30 | webtorrent (): WebTorrentPlugin | |
31 | ||
32 | p2pMediaLoader (): P2pMediaLoaderPlugin | |
33 | ||
34 | contextmenuUI (options: any): any | |
35 | ||
36 | bezels (): void | |
37 | ||
38 | qualityLevels (): QualityLevels | |
39 | ||
40 | textTracks (): TextTrackList & { | |
41 | on: Function | |
42 | tracks_: (TextTrack & { id: string, label: string, src: string })[] | |
43 | } | |
44 | ||
45 | dock (options: { title: string, description: string }): void | |
46 | ||
47 | upnext (options: Partial<EndCardOptions>): void | |
48 | } | |
49 | } | |
50 | ||
51 | export interface VideoJSTechHLS extends videojs.Tech { | |
52 | hlsProvider: any // FIXME: typings | |
53 | } | |
54 | ||
55 | export interface HlsjsConfigHandlerOptions { | |
56 | hlsjsConfig?: Config & { cueHandler: any }// FIXME: typings | |
57 | captionConfig?: any // FIXME: typings | |
58 | ||
59 | levelLabelHandler?: (level: Level) => string | |
60 | } | |
61 | ||
62 | type QualityLevelRepresentation = { | |
63 | id: number | |
64 | height: number | |
65 | ||
66 | label?: string | |
67 | width?: number | |
68 | bandwidth?: number | |
69 | bitrate?: number | |
70 | ||
71 | enabled?: Function | |
72 | _enabled: boolean | |
73 | } | |
74 | ||
75 | type QualityLevels = QualityLevelRepresentation[] & { | |
76 | selectedIndex: number | |
77 | selectedIndex_: number | |
78 | ||
79 | addQualityLevel (representation: QualityLevelRepresentation): void | |
80 | } | |
81 | ||
82 | type VideoJSCaption = { | |
83 | label: string | |
84 | language: string | |
85 | src: string | |
86 | } | |
87 | ||
88 | type UserWatching = { | |
89 | url: string, | |
90 | authorizationHeader: string | |
91 | } | |
92 | ||
93 | type PeerTubePluginOptions = { | |
94 | mode: PlayerMode | |
95 | ||
96 | autoplay: boolean | |
97 | videoViewUrl: string | |
98 | videoDuration: number | |
99 | ||
100 | userWatching?: UserWatching | |
101 | subtitle?: string | |
102 | ||
103 | videoCaptions: VideoJSCaption[] | |
104 | ||
105 | stopTime: number | string | |
106 | } | |
107 | ||
108 | type WebtorrentPluginOptions = { | |
109 | playerElement: HTMLVideoElement | |
110 | ||
111 | autoplay: boolean | |
112 | videoDuration: number | |
113 | ||
114 | videoFiles: VideoFile[] | |
115 | ||
116 | startTime: number | string | |
117 | } | |
118 | ||
119 | type P2PMediaLoaderPluginOptions = { | |
120 | redundancyUrlManager: RedundancyUrlManager | |
121 | type: string | |
122 | src: string | |
123 | ||
124 | startTime: number | string | |
125 | } | |
126 | ||
127 | type VideoJSPluginOptions = { | |
128 | peertube: PeerTubePluginOptions | |
129 | ||
130 | webtorrent?: WebtorrentPluginOptions | |
131 | ||
132 | p2pMediaLoader?: P2PMediaLoaderPluginOptions | |
133 | } | |
134 | ||
135 | type LoadedQualityData = { | |
136 | qualitySwitchCallback: Function, | |
137 | qualityData: { | |
138 | video: { | |
139 | id: number | |
140 | label: string | |
141 | selected: boolean | |
142 | }[] | |
143 | } | |
144 | } | |
145 | ||
146 | type ResolutionUpdateData = { | |
147 | auto: boolean, | |
148 | resolutionId: number | |
149 | id?: number | |
150 | } | |
151 | ||
152 | type AutoResolutionUpdateData = { | |
153 | possible: boolean | |
154 | } | |
155 | ||
156 | type PlayerNetworkInfo = { | |
157 | http: { | |
158 | downloadSpeed: number | |
159 | uploadSpeed: number | |
160 | downloaded: number | |
161 | uploaded: number | |
162 | } | |
163 | ||
164 | p2p: { | |
165 | downloadSpeed: number | |
166 | uploadSpeed: number | |
167 | downloaded: number | |
168 | uploaded: number | |
169 | numPeers: number | |
170 | } | |
171 | } | |
172 | ||
173 | export { | |
174 | PlayerNetworkInfo, | |
175 | ResolutionUpdateData, | |
176 | AutoResolutionUpdateData, | |
177 | VideoJSCaption, | |
178 | UserWatching, | |
179 | PeerTubePluginOptions, | |
180 | WebtorrentPluginOptions, | |
181 | P2PMediaLoaderPluginOptions, | |
182 | VideoJSPluginOptions, | |
183 | LoadedQualityData, | |
184 | QualityLevelRepresentation, | |
185 | QualityLevels | |
186 | } |