diff options
Diffstat (limited to 'client/src/assets/player/types')
-rw-r--r-- | client/src/assets/player/types/index.ts | 2 | ||||
-rw-r--r-- | client/src/assets/player/types/manager-options.ts | 84 | ||||
-rw-r--r-- | client/src/assets/player/types/peertube-videojs-typings.ts | 242 |
3 files changed, 328 insertions, 0 deletions
diff --git a/client/src/assets/player/types/index.ts b/client/src/assets/player/types/index.ts new file mode 100644 index 000000000..b73e0b3cb --- /dev/null +++ b/client/src/assets/player/types/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './manager-options' | ||
2 | export * from './peertube-videojs-typings' | ||
diff --git a/client/src/assets/player/types/manager-options.ts b/client/src/assets/player/types/manager-options.ts new file mode 100644 index 000000000..b3ad7e337 --- /dev/null +++ b/client/src/assets/player/types/manager-options.ts | |||
@@ -0,0 +1,84 @@ | |||
1 | import { PluginsManager } from '@root-helpers/plugins-manager' | ||
2 | import { LiveVideoLatencyMode, VideoFile } from '@shared/models' | ||
3 | import { PlaylistPluginOptions, UserWatching, VideoJSCaption } from './peertube-videojs-typings' | ||
4 | |||
5 | export type PlayerMode = 'webtorrent' | 'p2p-media-loader' | ||
6 | |||
7 | export type WebtorrentOptions = { | ||
8 | videoFiles: VideoFile[] | ||
9 | } | ||
10 | |||
11 | export type P2PMediaLoaderOptions = { | ||
12 | playlistUrl: string | ||
13 | segmentsSha256Url: string | ||
14 | trackerAnnounce: string[] | ||
15 | redundancyBaseUrls: string[] | ||
16 | videoFiles: VideoFile[] | ||
17 | } | ||
18 | |||
19 | export interface CustomizationOptions { | ||
20 | startTime: number | string | ||
21 | stopTime: number | string | ||
22 | |||
23 | controls?: boolean | ||
24 | muted?: boolean | ||
25 | loop?: boolean | ||
26 | subtitle?: string | ||
27 | resume?: string | ||
28 | |||
29 | peertubeLink: boolean | ||
30 | } | ||
31 | |||
32 | export interface CommonOptions extends CustomizationOptions { | ||
33 | playerElement: HTMLVideoElement | ||
34 | onPlayerElementChange: (element: HTMLVideoElement) => void | ||
35 | |||
36 | autoplay: boolean | ||
37 | p2pEnabled: boolean | ||
38 | |||
39 | nextVideo?: () => void | ||
40 | hasNextVideo?: () => boolean | ||
41 | |||
42 | previousVideo?: () => void | ||
43 | hasPreviousVideo?: () => boolean | ||
44 | |||
45 | playlist?: PlaylistPluginOptions | ||
46 | |||
47 | videoDuration: number | ||
48 | enableHotkeys: boolean | ||
49 | inactivityTimeout: number | ||
50 | poster: string | ||
51 | |||
52 | theaterButton: boolean | ||
53 | captions: boolean | ||
54 | |||
55 | videoViewUrl: string | ||
56 | embedUrl: string | ||
57 | embedTitle: string | ||
58 | |||
59 | isLive: boolean | ||
60 | liveOptions?: { | ||
61 | latencyMode: LiveVideoLatencyMode | ||
62 | } | ||
63 | |||
64 | language?: string | ||
65 | |||
66 | videoCaptions: VideoJSCaption[] | ||
67 | |||
68 | videoUUID: string | ||
69 | videoShortUUID: string | ||
70 | |||
71 | userWatching?: UserWatching | ||
72 | |||
73 | serverUrl: string | ||
74 | |||
75 | errorNotifier: (message: string) => void | ||
76 | } | ||
77 | |||
78 | export type PeertubePlayerManagerOptions = { | ||
79 | common: CommonOptions | ||
80 | webtorrent: WebtorrentOptions | ||
81 | p2pMediaLoader?: P2PMediaLoaderOptions | ||
82 | |||
83 | pluginsManager: PluginsManager | ||
84 | } | ||
diff --git a/client/src/assets/player/types/peertube-videojs-typings.ts b/client/src/assets/player/types/peertube-videojs-typings.ts new file mode 100644 index 000000000..d9a388681 --- /dev/null +++ b/client/src/assets/player/types/peertube-videojs-typings.ts | |||
@@ -0,0 +1,242 @@ | |||
1 | import { HlsConfig, Level } from 'hls.js' | ||
2 | import videojs from 'video.js' | ||
3 | import { Engine } from '@peertube/p2p-media-loader-hlsjs' | ||
4 | import { VideoFile, VideoPlaylist, VideoPlaylistElement } from '@shared/models' | ||
5 | import { PeerTubeDockPluginOptions } from '../shared/dock/peertube-dock-plugin' | ||
6 | import { Html5Hlsjs } from '../shared/p2p-media-loader/hls-plugin' | ||
7 | import { P2pMediaLoaderPlugin } from '../shared/p2p-media-loader/p2p-media-loader-plugin' | ||
8 | import { RedundancyUrlManager } from '../shared/p2p-media-loader/redundancy-url-manager' | ||
9 | import { PeerTubePlugin } from '../shared/peertube/peertube-plugin' | ||
10 | import { PlaylistPlugin } from '../shared/playlist/playlist-plugin' | ||
11 | import { PeerTubeResolutionsPlugin } from '../shared/resolutions/peertube-resolutions-plugin' | ||
12 | import { StatsCardOptions } from '../shared/stats/stats-card' | ||
13 | import { StatsForNerdsPlugin } from '../shared/stats/stats-plugin' | ||
14 | import { EndCardOptions } from '../shared/upnext/end-card' | ||
15 | import { WebTorrentPlugin } from '../shared/webtorrent/webtorrent-plugin' | ||
16 | import { PlayerMode } from './manager-options' | ||
17 | |||
18 | declare module 'video.js' { | ||
19 | |||
20 | export interface VideoJsPlayer { | ||
21 | srOptions_: HlsjsConfigHandlerOptions | ||
22 | |||
23 | theaterEnabled: boolean | ||
24 | |||
25 | // FIXME: add it to upstream typings | ||
26 | posterImage: { | ||
27 | show (): void | ||
28 | hide (): void | ||
29 | } | ||
30 | |||
31 | handleTechSeeked_ (): void | ||
32 | |||
33 | // Plugins | ||
34 | |||
35 | peertube (): PeerTubePlugin | ||
36 | |||
37 | webtorrent (): WebTorrentPlugin | ||
38 | |||
39 | p2pMediaLoader (): P2pMediaLoaderPlugin | ||
40 | |||
41 | peertubeResolutions (): PeerTubeResolutionsPlugin | ||
42 | |||
43 | contextmenuUI (options: any): any | ||
44 | |||
45 | bezels (): void | ||
46 | peertubeMobile (): void | ||
47 | peerTubeHotkeysPlugin (): void | ||
48 | |||
49 | stats (options?: StatsCardOptions): StatsForNerdsPlugin | ||
50 | |||
51 | textTracks (): TextTrackList & { | ||
52 | tracks_: (TextTrack & { id: string, label: string, src: string })[] | ||
53 | } | ||
54 | |||
55 | peertubeDock (options: PeerTubeDockPluginOptions): void | ||
56 | |||
57 | upnext (options: Partial<EndCardOptions>): void | ||
58 | |||
59 | playlist (): PlaylistPlugin | ||
60 | } | ||
61 | } | ||
62 | |||
63 | export interface VideoJSTechHLS extends videojs.Tech { | ||
64 | hlsProvider: Html5Hlsjs | ||
65 | } | ||
66 | |||
67 | export interface HlsjsConfigHandlerOptions { | ||
68 | hlsjsConfig?: HlsConfig | ||
69 | |||
70 | levelLabelHandler?: (level: Level) => string | ||
71 | } | ||
72 | |||
73 | type PeerTubeResolution = { | ||
74 | id: number | ||
75 | |||
76 | height?: number | ||
77 | label?: string | ||
78 | width?: number | ||
79 | bitrate?: number | ||
80 | |||
81 | selected: boolean | ||
82 | selectCallback: () => void | ||
83 | } | ||
84 | |||
85 | type VideoJSCaption = { | ||
86 | label: string | ||
87 | language: string | ||
88 | src: string | ||
89 | } | ||
90 | |||
91 | type UserWatching = { | ||
92 | url: string | ||
93 | authorizationHeader: string | ||
94 | } | ||
95 | |||
96 | type PeerTubePluginOptions = { | ||
97 | mode: PlayerMode | ||
98 | |||
99 | autoplay: boolean | ||
100 | videoViewUrl: string | ||
101 | videoDuration: number | ||
102 | |||
103 | userWatching?: UserWatching | ||
104 | subtitle?: string | ||
105 | |||
106 | videoCaptions: VideoJSCaption[] | ||
107 | |||
108 | stopTime: number | string | ||
109 | |||
110 | isLive: boolean | ||
111 | |||
112 | videoUUID: string | ||
113 | } | ||
114 | |||
115 | type PlaylistPluginOptions = { | ||
116 | elements: VideoPlaylistElement[] | ||
117 | |||
118 | playlist: VideoPlaylist | ||
119 | |||
120 | getCurrentPosition: () => number | ||
121 | |||
122 | onItemClicked: (element: VideoPlaylistElement) => void | ||
123 | } | ||
124 | |||
125 | type NextPreviousVideoButtonOptions = { | ||
126 | type: 'next' | 'previous' | ||
127 | handler: () => void | ||
128 | isDisabled: () => boolean | ||
129 | } | ||
130 | |||
131 | type PeerTubeLinkButtonOptions = { | ||
132 | shortUUID: string | ||
133 | } | ||
134 | |||
135 | type PeerTubeP2PInfoButtonOptions = { | ||
136 | p2pEnabled: boolean | ||
137 | } | ||
138 | |||
139 | type WebtorrentPluginOptions = { | ||
140 | playerElement: HTMLVideoElement | ||
141 | |||
142 | autoplay: boolean | ||
143 | videoDuration: number | ||
144 | |||
145 | videoFiles: VideoFile[] | ||
146 | |||
147 | startTime: number | string | ||
148 | |||
149 | playerRefusedP2P: boolean | ||
150 | } | ||
151 | |||
152 | type P2PMediaLoaderPluginOptions = { | ||
153 | redundancyUrlManager: RedundancyUrlManager | ||
154 | type: string | ||
155 | src: string | ||
156 | |||
157 | startTime: number | string | ||
158 | |||
159 | loader: P2PMediaLoader | ||
160 | } | ||
161 | |||
162 | export type P2PMediaLoader = { | ||
163 | getEngine(): Engine | ||
164 | } | ||
165 | |||
166 | type VideoJSPluginOptions = { | ||
167 | playlist?: PlaylistPluginOptions | ||
168 | |||
169 | peertube: PeerTubePluginOptions | ||
170 | |||
171 | webtorrent?: WebtorrentPluginOptions | ||
172 | |||
173 | p2pMediaLoader?: P2PMediaLoaderPluginOptions | ||
174 | } | ||
175 | |||
176 | type LoadedQualityData = { | ||
177 | qualitySwitchCallback: (resolutionId: number, type: 'video') => void | ||
178 | qualityData: { | ||
179 | video: { | ||
180 | id: number | ||
181 | label: string | ||
182 | selected: boolean | ||
183 | }[] | ||
184 | } | ||
185 | } | ||
186 | |||
187 | type ResolutionUpdateData = { | ||
188 | auto: boolean | ||
189 | resolutionId: number | ||
190 | id?: number | ||
191 | } | ||
192 | |||
193 | type AutoResolutionUpdateData = { | ||
194 | possible: boolean | ||
195 | } | ||
196 | |||
197 | type PlayerNetworkInfo = { | ||
198 | source: 'webtorrent' | 'p2p-media-loader' | ||
199 | |||
200 | http: { | ||
201 | downloadSpeed: number | ||
202 | uploadSpeed: number | ||
203 | downloaded: number | ||
204 | uploaded: number | ||
205 | } | ||
206 | |||
207 | p2p: { | ||
208 | downloadSpeed: number | ||
209 | uploadSpeed: number | ||
210 | downloaded: number | ||
211 | uploaded: number | ||
212 | numPeers: number | ||
213 | } | ||
214 | |||
215 | // In bytes | ||
216 | bandwidthEstimate: number | ||
217 | } | ||
218 | |||
219 | type PlaylistItemOptions = { | ||
220 | element: VideoPlaylistElement | ||
221 | |||
222 | onClicked: () => void | ||
223 | } | ||
224 | |||
225 | export { | ||
226 | PlayerNetworkInfo, | ||
227 | PlaylistItemOptions, | ||
228 | NextPreviousVideoButtonOptions, | ||
229 | ResolutionUpdateData, | ||
230 | AutoResolutionUpdateData, | ||
231 | PlaylistPluginOptions, | ||
232 | VideoJSCaption, | ||
233 | UserWatching, | ||
234 | PeerTubePluginOptions, | ||
235 | WebtorrentPluginOptions, | ||
236 | P2PMediaLoaderPluginOptions, | ||
237 | PeerTubeResolution, | ||
238 | VideoJSPluginOptions, | ||
239 | LoadedQualityData, | ||
240 | PeerTubeLinkButtonOptions, | ||
241 | PeerTubeP2PInfoButtonOptions | ||
242 | } | ||