@phont-ai/subtitles 0.1.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CameraClicking-QIQOCMH2.js +1 -0
- package/dist/CameraClicking-STYUWJBR.mjs +1 -0
- package/dist/Crack-BBGD7J55.mjs +1 -0
- package/dist/Crack-DRH2BJLA.js +1 -0
- package/dist/Siren-JPN2DU4H.js +1 -0
- package/dist/Siren-LZ5D5FNA.mjs +1 -0
- package/dist/Vibration-2GSA3SGI.js +1 -0
- package/dist/Vibration-7W5U2SOY.mjs +1 -0
- package/dist/chunk-EK7ODJWE.js +1 -0
- package/dist/chunk-YEKQJ4YC.mjs +1 -0
- package/dist/esm-35JNMGFN.mjs +1 -0
- package/dist/esm-IPWYT3AN.js +1 -0
- package/dist/index.d.mts +697 -0
- package/dist/index.d.ts +697 -0
- package/dist/index.js +93492 -0
- package/dist/index.mjs +93475 -0
- package/dist/styles.css +1108 -0
- package/package.json +44 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,697 @@
|
|
|
1
|
+
import { PhontClient, LoginResponse, RegisterResponse, SentenceAnimationState, WordAnimationState, EMOTION_ANIMATIONS } from '@phont-ai/subtitles-core';
|
|
2
|
+
export { LoginResponse, PhontClient, PhontClientOptions, RegisterResponse, VodMetadata, subtitleManager } from '@phont-ai/subtitles-core';
|
|
3
|
+
import React, { ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
interface PhontClientConfig {
|
|
6
|
+
apiKey: string;
|
|
7
|
+
apiBaseUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* PhontSubtitles Component
|
|
12
|
+
*
|
|
13
|
+
* Main SDK component for rendering expressive subtitles
|
|
14
|
+
* Handles subtitle fetching, animation, and rendering
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
interface PhontSubtitlesProps {
|
|
18
|
+
vodId: string;
|
|
19
|
+
currentTime: number;
|
|
20
|
+
isPlaying?: boolean;
|
|
21
|
+
mode?: 'sentence' | 'word';
|
|
22
|
+
language?: string | null;
|
|
23
|
+
maxExpression?: number;
|
|
24
|
+
threshold?: number;
|
|
25
|
+
isRTL?: boolean;
|
|
26
|
+
phontClient?: PhontClient | null;
|
|
27
|
+
className?: string;
|
|
28
|
+
style?: React.CSSProperties;
|
|
29
|
+
subtitleAvailable?: boolean;
|
|
30
|
+
}
|
|
31
|
+
declare function PhontSubtitles({ vodId, currentTime, isPlaying, mode, // Default to word-by-word mode
|
|
32
|
+
language, maxExpression, threshold, isRTL, phontClient, className, style, subtitleAvailable, }: PhontSubtitlesProps): React.JSX.Element | null;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* SDK Authentication Hook
|
|
36
|
+
*
|
|
37
|
+
* IMPORTANT:
|
|
38
|
+
* This hook must behave like a singleton across the app.
|
|
39
|
+
* Multiple components (e.g. `SDKAuth` + `/sdk` page) call `useSDKAuth()`.
|
|
40
|
+
* If each call has its own `useState`, login/logout will not reliably refresh UI.
|
|
41
|
+
*
|
|
42
|
+
* We implement a tiny shared store via `useSyncExternalStore`.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
interface SDKAuthState {
|
|
46
|
+
isAuthenticated: boolean;
|
|
47
|
+
authToken: string | null;
|
|
48
|
+
sessionId: string | null;
|
|
49
|
+
tenantId: string | null;
|
|
50
|
+
username: string | null;
|
|
51
|
+
apiKey: string | null;
|
|
52
|
+
phontClient: PhontClient | null;
|
|
53
|
+
}
|
|
54
|
+
declare function useSDKAuth(apiBaseUrl?: string): {
|
|
55
|
+
login: (identifier: string, password: string) => Promise<LoginResponse>;
|
|
56
|
+
register: (username: string, email: string, password: string) => Promise<RegisterResponse>;
|
|
57
|
+
setApiKey: (apiKey: string) => void;
|
|
58
|
+
logout: () => void;
|
|
59
|
+
refreshAuth: () => void;
|
|
60
|
+
isAuthenticated: boolean;
|
|
61
|
+
authToken: string | null;
|
|
62
|
+
sessionId: string | null;
|
|
63
|
+
tenantId: string | null;
|
|
64
|
+
username: string | null;
|
|
65
|
+
apiKey: string | null;
|
|
66
|
+
phontClient: PhontClient | null;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* SDK Authentication Component
|
|
71
|
+
*
|
|
72
|
+
* Provides UI for login, registration, and API key entry
|
|
73
|
+
* Matches the style and simplicity of StagingLogin
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
interface SDKAuthProps {
|
|
77
|
+
apiBaseUrl?: string;
|
|
78
|
+
onAuthenticated?: (client: any) => void;
|
|
79
|
+
}
|
|
80
|
+
declare function SDKAuth({ apiBaseUrl, onAuthenticated }: SDKAuthProps): React.JSX.Element;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* SDK Animation Hook
|
|
84
|
+
*
|
|
85
|
+
* Combines SubtitleManager + emotion selection + URL animation
|
|
86
|
+
* Uses @phont/subtitles-core packages
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
interface UseSDKAnimationOptions {
|
|
90
|
+
vodId: string;
|
|
91
|
+
currentTime: number;
|
|
92
|
+
mode: 'sentence' | 'word';
|
|
93
|
+
maxExpression?: number;
|
|
94
|
+
threshold?: number;
|
|
95
|
+
isRTL?: boolean;
|
|
96
|
+
language?: string | null;
|
|
97
|
+
phontClient?: PhontClient | null;
|
|
98
|
+
}
|
|
99
|
+
declare function useSDKAnimation(options: UseSDKAnimationOptions): {
|
|
100
|
+
animationState: SentenceAnimationState | WordAnimationState;
|
|
101
|
+
isLoading: boolean;
|
|
102
|
+
segment: any;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Player Adapter Interface
|
|
107
|
+
*
|
|
108
|
+
* Abstract interface for video player integration
|
|
109
|
+
* Allows PhontSubtitles to work with any video player (HTML5, Bitmovin, Shaka, etc.)
|
|
110
|
+
*/
|
|
111
|
+
interface PlayerAdapter {
|
|
112
|
+
/**
|
|
113
|
+
* Get current playback time in seconds
|
|
114
|
+
*/
|
|
115
|
+
getCurrentTime(): number;
|
|
116
|
+
/**
|
|
117
|
+
* Check if video is currently playing
|
|
118
|
+
*/
|
|
119
|
+
isPlaying(): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Subscribe to time updates
|
|
122
|
+
* @param callback Function called when playback time changes
|
|
123
|
+
* @returns Unsubscribe function
|
|
124
|
+
*/
|
|
125
|
+
onTimeUpdate(callback: (currentTime: number) => void): () => void;
|
|
126
|
+
/**
|
|
127
|
+
* Subscribe to play state changes
|
|
128
|
+
* @param callback Function called when play/pause state changes
|
|
129
|
+
* @returns Unsubscribe function
|
|
130
|
+
*/
|
|
131
|
+
onPlayStateChange(callback: (isPlaying: boolean) => void): () => void;
|
|
132
|
+
/**
|
|
133
|
+
* Optional: Get video duration (for debugging/validation)
|
|
134
|
+
*/
|
|
135
|
+
getDuration?(): number | null;
|
|
136
|
+
/**
|
|
137
|
+
* Optional: Seek to a specific time (for testing/debugging)
|
|
138
|
+
*/
|
|
139
|
+
seek?(time: number): void;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* HTML5 Video Player Adapter
|
|
144
|
+
*
|
|
145
|
+
* Adapter for native HTML5 video elements
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
declare class HTML5VideoAdapter implements PlayerAdapter {
|
|
149
|
+
private videoElement;
|
|
150
|
+
constructor(videoElement: HTMLVideoElement);
|
|
151
|
+
getCurrentTime(): number;
|
|
152
|
+
isPlaying(): boolean;
|
|
153
|
+
onTimeUpdate(callback: (currentTime: number) => void): () => void;
|
|
154
|
+
onPlayStateChange(callback: (isPlaying: boolean) => void): () => void;
|
|
155
|
+
getDuration(): number | null;
|
|
156
|
+
seek(time: number): void;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Bitmovin Player Adapter
|
|
161
|
+
*
|
|
162
|
+
* Adapter for Bitmovin Player
|
|
163
|
+
* Documentation: https://developer.bitmovin.com/playback/docs
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
interface BitmovinPlayer {
|
|
167
|
+
getCurrentTime(): number;
|
|
168
|
+
play(): Promise<void>;
|
|
169
|
+
pause(): void;
|
|
170
|
+
seek(time: number): void;
|
|
171
|
+
getDuration(): number;
|
|
172
|
+
on(event: string, callback: (event?: any) => void): void;
|
|
173
|
+
off(event: string, callback: (event?: any) => void): void;
|
|
174
|
+
isPaused(): boolean;
|
|
175
|
+
isPlaying(): boolean;
|
|
176
|
+
getContainer(): HTMLElement | null;
|
|
177
|
+
}
|
|
178
|
+
declare class BitmovinPlayerAdapter implements PlayerAdapter {
|
|
179
|
+
private player;
|
|
180
|
+
private videoElement;
|
|
181
|
+
private timeUpdateCallbacks;
|
|
182
|
+
private playStateCallbacks;
|
|
183
|
+
private timeUpdateHandler?;
|
|
184
|
+
private playHandler?;
|
|
185
|
+
private pauseHandler?;
|
|
186
|
+
constructor(player: BitmovinPlayer, videoElement: HTMLVideoElement);
|
|
187
|
+
private setupEventListeners;
|
|
188
|
+
getCurrentTime(): number;
|
|
189
|
+
isPlaying(): boolean;
|
|
190
|
+
onTimeUpdate(callback: (currentTime: number) => void): () => void;
|
|
191
|
+
onPlayStateChange(callback: (isPlaying: boolean) => void): () => void;
|
|
192
|
+
getDuration(): number | null;
|
|
193
|
+
seek(time: number): void;
|
|
194
|
+
/**
|
|
195
|
+
* Cleanup - remove all event listeners
|
|
196
|
+
*/
|
|
197
|
+
destroy(): void;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Shaka Player Adapter
|
|
202
|
+
*
|
|
203
|
+
* Adapter for Shaka Player
|
|
204
|
+
* Documentation: https://shaka-player-demo.appspot.com/docs/api/index.html
|
|
205
|
+
*
|
|
206
|
+
* Note: Shaka Player uses HTML5 video element directly, so we can use HTML5VideoAdapter
|
|
207
|
+
* OR create a Shaka-specific adapter if you want to use Shaka's API methods
|
|
208
|
+
*/
|
|
209
|
+
|
|
210
|
+
interface ShakaPlayer {
|
|
211
|
+
getVideoElement?(): HTMLVideoElement;
|
|
212
|
+
getCurrentTime(): number;
|
|
213
|
+
play(): Promise<void>;
|
|
214
|
+
pause(): void;
|
|
215
|
+
seek(time: number): void;
|
|
216
|
+
getDuration(): number;
|
|
217
|
+
addEventListener?(event: string, callback: (event?: any) => void): void;
|
|
218
|
+
removeEventListener?(event: string, callback: (event?: any) => void): void;
|
|
219
|
+
videoElement?: HTMLVideoElement;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Shaka Player Adapter
|
|
223
|
+
*
|
|
224
|
+
* Shaka Player wraps an HTML5 video element, so we can either:
|
|
225
|
+
* 1. Use HTML5VideoAdapter with player.getVideoElement() (simpler)
|
|
226
|
+
* 2. Use Shaka's API methods (this adapter)
|
|
227
|
+
*
|
|
228
|
+
* This adapter uses Shaka's API for consistency, but you can also use HTML5VideoAdapter
|
|
229
|
+
*/
|
|
230
|
+
declare class ShakaPlayerAdapter implements PlayerAdapter {
|
|
231
|
+
private player;
|
|
232
|
+
private videoElement;
|
|
233
|
+
private timeUpdateCallbacks;
|
|
234
|
+
private playStateCallbacks;
|
|
235
|
+
private timeUpdateHandler?;
|
|
236
|
+
private playHandler?;
|
|
237
|
+
private pauseHandler?;
|
|
238
|
+
constructor(player: ShakaPlayer, videoElement: HTMLVideoElement);
|
|
239
|
+
private setupEventListeners;
|
|
240
|
+
getCurrentTime(): number;
|
|
241
|
+
isPlaying(): boolean;
|
|
242
|
+
onTimeUpdate(callback: (currentTime: number) => void): () => void;
|
|
243
|
+
onPlayStateChange(callback: (isPlaying: boolean) => void): () => void;
|
|
244
|
+
getDuration(): number | null;
|
|
245
|
+
seek(time: number): void;
|
|
246
|
+
/**
|
|
247
|
+
* Cleanup - remove all event listeners
|
|
248
|
+
*/
|
|
249
|
+
destroy(): void;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Video.js Player Adapter
|
|
254
|
+
*
|
|
255
|
+
* Adapter for Video.js Player
|
|
256
|
+
* Documentation: https://videojs.com/guides/api/
|
|
257
|
+
*/
|
|
258
|
+
|
|
259
|
+
interface VideoJSPlayer {
|
|
260
|
+
currentTime(): number;
|
|
261
|
+
currentTime(time: number): void;
|
|
262
|
+
play(): Promise<void> | void;
|
|
263
|
+
pause(): void;
|
|
264
|
+
duration(): number;
|
|
265
|
+
paused(): boolean;
|
|
266
|
+
on(event: string, callback: (event?: any) => void): void;
|
|
267
|
+
off(event: string, callback: (event?: any) => void): void;
|
|
268
|
+
ready(callback: () => void): void;
|
|
269
|
+
}
|
|
270
|
+
declare class VideoJSPlayerAdapter implements PlayerAdapter {
|
|
271
|
+
private player;
|
|
272
|
+
private videoElement;
|
|
273
|
+
private timeUpdateCallbacks;
|
|
274
|
+
private playStateCallbacks;
|
|
275
|
+
private timeUpdateHandler?;
|
|
276
|
+
private playHandler?;
|
|
277
|
+
private pauseHandler?;
|
|
278
|
+
constructor(player: VideoJSPlayer, videoElement: HTMLVideoElement);
|
|
279
|
+
private setupEventListeners;
|
|
280
|
+
getCurrentTime(): number;
|
|
281
|
+
isPlaying(): boolean;
|
|
282
|
+
onTimeUpdate(callback: (currentTime: number) => void): () => void;
|
|
283
|
+
onPlayStateChange(callback: (isPlaying: boolean) => void): () => void;
|
|
284
|
+
getDuration(): number | null;
|
|
285
|
+
seek(time: number): void;
|
|
286
|
+
/**
|
|
287
|
+
* Cleanup - remove all event listeners
|
|
288
|
+
*/
|
|
289
|
+
destroy(): void;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* 3Q Video Player Adapter
|
|
294
|
+
*
|
|
295
|
+
* Adapter for 3Q Video Player
|
|
296
|
+
* Documentation: https://player.docs.3q.video/player-web-sdk/configuration
|
|
297
|
+
*/
|
|
298
|
+
|
|
299
|
+
interface ThreeQPlayer {
|
|
300
|
+
getCurrentTime(): number;
|
|
301
|
+
play(): Promise<void>;
|
|
302
|
+
pause(): void;
|
|
303
|
+
seek(time: number): void;
|
|
304
|
+
getDuration(): number;
|
|
305
|
+
isPaused(): boolean;
|
|
306
|
+
isPlaying(): boolean;
|
|
307
|
+
on(event: string, callback: (event?: any) => void): void;
|
|
308
|
+
off(event: string, callback: (event?: any) => void): void;
|
|
309
|
+
getContainer?(): HTMLElement | null;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* 3Q Video Player Adapter
|
|
313
|
+
*
|
|
314
|
+
* 3Q Player renders into a container div, and we access the video element
|
|
315
|
+
* from the container (similar to Bitmovin pattern).
|
|
316
|
+
*/
|
|
317
|
+
declare class ThreeQPlayerAdapter implements PlayerAdapter {
|
|
318
|
+
private player;
|
|
319
|
+
private videoElement;
|
|
320
|
+
private timeUpdateCallbacks;
|
|
321
|
+
private playStateCallbacks;
|
|
322
|
+
private timeUpdateHandler?;
|
|
323
|
+
private playHandler?;
|
|
324
|
+
private pauseHandler?;
|
|
325
|
+
private threeqTimeUpdateHandler?;
|
|
326
|
+
private threeqPlayHandler?;
|
|
327
|
+
private threeqPauseHandler?;
|
|
328
|
+
private timeUpdateInterval;
|
|
329
|
+
constructor(player: ThreeQPlayer, videoElement: HTMLVideoElement);
|
|
330
|
+
private setupEventListeners;
|
|
331
|
+
getCurrentTime(): number;
|
|
332
|
+
isPlaying(): boolean;
|
|
333
|
+
onTimeUpdate(callback: (currentTime: number) => void): () => void;
|
|
334
|
+
onPlayStateChange(callback: (isPlaying: boolean) => void): () => void;
|
|
335
|
+
getDuration(): number | null;
|
|
336
|
+
seek(time: number): void;
|
|
337
|
+
/**
|
|
338
|
+
* Cleanup - remove all event listeners
|
|
339
|
+
*/
|
|
340
|
+
destroy(): void;
|
|
341
|
+
private stopTimeUpdatePolling;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* usePlayerSync Hook
|
|
346
|
+
*
|
|
347
|
+
* Syncs PhontSubtitles with any video player via PlayerAdapter
|
|
348
|
+
* This hook bridges the gap between player-agnostic adapters and React components
|
|
349
|
+
*/
|
|
350
|
+
|
|
351
|
+
interface UsePlayerSyncOptions {
|
|
352
|
+
player: PlayerAdapter | null;
|
|
353
|
+
updateInterval?: number;
|
|
354
|
+
}
|
|
355
|
+
interface UsePlayerSyncResult {
|
|
356
|
+
currentTime: number;
|
|
357
|
+
isPlaying: boolean;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Hook to sync with any video player via PlayerAdapter
|
|
361
|
+
*
|
|
362
|
+
* @example
|
|
363
|
+
* ```tsx
|
|
364
|
+
* const adapter = new HTML5VideoAdapter(videoRef.current);
|
|
365
|
+
* const { currentTime, isPlaying } = usePlayerSync({ player: adapter });
|
|
366
|
+
*
|
|
367
|
+
* <PhontSubtitles
|
|
368
|
+
* vodId={vodId}
|
|
369
|
+
* currentTime={currentTime}
|
|
370
|
+
* isPlaying={isPlaying}
|
|
371
|
+
* // ... other props
|
|
372
|
+
* />
|
|
373
|
+
* ```
|
|
374
|
+
*/
|
|
375
|
+
declare function usePlayerSync(options: UsePlayerSyncOptions): UsePlayerSyncResult;
|
|
376
|
+
|
|
377
|
+
interface UseVideoPlayerOptions {
|
|
378
|
+
/** HTML5 video element */
|
|
379
|
+
video?: HTMLVideoElement | null;
|
|
380
|
+
/** Bitmovin player instance */
|
|
381
|
+
bitmovin?: BitmovinPlayer | null;
|
|
382
|
+
/** Bitmovin video element (optional, will try to get from player container if not provided) */
|
|
383
|
+
bitmovinVideo?: HTMLVideoElement | null;
|
|
384
|
+
/** Shaka player instance */
|
|
385
|
+
shaka?: ShakaPlayer | null;
|
|
386
|
+
/** Shaka video element (optional, will try to get from player if not provided) */
|
|
387
|
+
shakaVideo?: HTMLVideoElement | null;
|
|
388
|
+
/** Video.js player instance */
|
|
389
|
+
videojs?: VideoJSPlayer | null;
|
|
390
|
+
/** Video.js video element (optional, will try to get from player if not provided) */
|
|
391
|
+
videojsVideo?: HTMLVideoElement | null;
|
|
392
|
+
/** 3Q Video Player instance */
|
|
393
|
+
threeq?: ThreeQPlayer | null;
|
|
394
|
+
/** 3Q container element (optional, will try to get video from player container if not provided) */
|
|
395
|
+
threeqContainer?: HTMLElement | null;
|
|
396
|
+
/** 3Q video element (optional, will auto-detect from container if not provided) */
|
|
397
|
+
threeqVideo?: HTMLVideoElement | null;
|
|
398
|
+
/** Custom player adapter (for advanced use cases) */
|
|
399
|
+
adapter?: PlayerAdapter | null;
|
|
400
|
+
/** Custom update interval in ms (optional, uses player events by default) */
|
|
401
|
+
updateInterval?: number;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Automatically creates the right adapter and syncs with your video player.
|
|
405
|
+
*
|
|
406
|
+
* Just pass your player instance and get back currentTime and isPlaying.
|
|
407
|
+
* Works with HTML5, Bitmovin, Shaka, Video.js, 3Q Video Player, or any custom adapter.
|
|
408
|
+
*/
|
|
409
|
+
declare function useVideoPlayer(options: UseVideoPlayerOptions): UsePlayerSyncResult;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* PhontVideoPlayer Component
|
|
413
|
+
*
|
|
414
|
+
* All-in-one component that combines video player + PHONT subtitles.
|
|
415
|
+
* The easiest way to add expressive subtitles to any video player.
|
|
416
|
+
*
|
|
417
|
+
* @example
|
|
418
|
+
* ```tsx
|
|
419
|
+
* // HTML5 Video
|
|
420
|
+
* <PhontVideoPlayer
|
|
421
|
+
* videoRef={videoRef}
|
|
422
|
+
* vodId="your-vod-id"
|
|
423
|
+
* phontClient={client}
|
|
424
|
+
* />
|
|
425
|
+
*
|
|
426
|
+
* // Bitmovin
|
|
427
|
+
* <PhontVideoPlayer
|
|
428
|
+
* bitmovin={bitmovinPlayer}
|
|
429
|
+
* vodId="your-vod-id"
|
|
430
|
+
* phontClient={client}
|
|
431
|
+
* />
|
|
432
|
+
*
|
|
433
|
+
* // 3Q Video Player (video element auto-detected)
|
|
434
|
+
* <PhontVideoPlayer
|
|
435
|
+
* threeq={threeqPlayer}
|
|
436
|
+
* vodId="your-vod-id"
|
|
437
|
+
* phontClient={client}
|
|
438
|
+
* />
|
|
439
|
+
* ```
|
|
440
|
+
*/
|
|
441
|
+
|
|
442
|
+
interface PhontVideoPlayerProps extends Omit<PhontSubtitlesProps, 'currentTime' | 'isPlaying'> {
|
|
443
|
+
/** HTML5 video element ref */
|
|
444
|
+
video?: HTMLVideoElement | null;
|
|
445
|
+
/** Bitmovin player instance */
|
|
446
|
+
bitmovin?: BitmovinPlayer | null;
|
|
447
|
+
/** Shaka player instance */
|
|
448
|
+
shaka?: ShakaPlayer | null;
|
|
449
|
+
/** Video.js player instance */
|
|
450
|
+
videojs?: VideoJSPlayer | null;
|
|
451
|
+
/** 3Q Video Player instance */
|
|
452
|
+
threeq?: ThreeQPlayer | null;
|
|
453
|
+
/** 3Q container element (optional, will try to get video from player container if not provided) */
|
|
454
|
+
threeqContainer?: HTMLElement | null;
|
|
455
|
+
/** 3Q video element (optional, will auto-detect from container if not provided) */
|
|
456
|
+
threeqVideo?: HTMLVideoElement | null;
|
|
457
|
+
/** Custom player adapter (for advanced use cases) */
|
|
458
|
+
adapter?: PlayerAdapter | null;
|
|
459
|
+
/** Custom update interval in ms */
|
|
460
|
+
updateInterval?: number;
|
|
461
|
+
/** Children to render (your video player UI) */
|
|
462
|
+
children?: React.ReactNode;
|
|
463
|
+
/** Subtitle container className */
|
|
464
|
+
subtitleClassName?: string;
|
|
465
|
+
/** Subtitle container style */
|
|
466
|
+
subtitleStyle?: React.CSSProperties;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* All-in-one component for video + PHONT subtitles.
|
|
470
|
+
*
|
|
471
|
+
* Automatically syncs with your video player and renders subtitles.
|
|
472
|
+
* Works with HTML5, Bitmovin, Shaka, Video.js, 3Q Video Player, or any custom adapter.
|
|
473
|
+
*/
|
|
474
|
+
declare function PhontVideoPlayer(props: PhontVideoPlayerProps): React.JSX.Element;
|
|
475
|
+
|
|
476
|
+
interface PositionConfig {
|
|
477
|
+
bottomVh: number;
|
|
478
|
+
bottomVhNoSpeaker: number;
|
|
479
|
+
mobileBottomVh: number;
|
|
480
|
+
mobileBottomVhNoSpeaker: number;
|
|
481
|
+
zIndex: number;
|
|
482
|
+
width: number | string;
|
|
483
|
+
mobileWidth: string;
|
|
484
|
+
maxMobileWidth: number | string;
|
|
485
|
+
height: number | string;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
interface SoundbiteContainerProps {
|
|
489
|
+
isVodMode?: boolean;
|
|
490
|
+
boxSize?: number;
|
|
491
|
+
width?: string | number | null;
|
|
492
|
+
height?: string | number | null;
|
|
493
|
+
bottomVh?: number | null;
|
|
494
|
+
intensity?: number;
|
|
495
|
+
hideWhenPanelsOpen?: boolean;
|
|
496
|
+
isMetaPanelOpen?: boolean;
|
|
497
|
+
isPhontControlsOpen?: boolean;
|
|
498
|
+
config?: Partial<PositionConfig>;
|
|
499
|
+
}
|
|
500
|
+
declare function SoundbiteContainer({ isVodMode, boxSize, width, height, bottomVh, intensity, hideWhenPanelsOpen, isMetaPanelOpen, isPhontControlsOpen, config }: SoundbiteContainerProps): React.JSX.Element | null;
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* PlayerTestSuite - Standalone Test Component
|
|
504
|
+
*
|
|
505
|
+
* A single importable React component that tests all video players with PHONT subtitles.
|
|
506
|
+
* Can be imported into any React app (Next.js, Vite, Create React App, etc.)
|
|
507
|
+
*
|
|
508
|
+
* Usage:
|
|
509
|
+
* ```tsx
|
|
510
|
+
* import { PlayerTestSuite } from '@phont-ai/subtitles';
|
|
511
|
+
*
|
|
512
|
+
* function App() {
|
|
513
|
+
* return <PlayerTestSuite />;
|
|
514
|
+
* }
|
|
515
|
+
* ```
|
|
516
|
+
*
|
|
517
|
+
* This component includes:
|
|
518
|
+
* - Authentication UI
|
|
519
|
+
* - Player selector (HTML5, Bitmovin, Shaka, 3Q)
|
|
520
|
+
* - Subtitle controls (mode, VOD selection)
|
|
521
|
+
* - Real-time player state display
|
|
522
|
+
*/
|
|
523
|
+
|
|
524
|
+
type PlayerType = 'html5' | 'bitmovin' | 'shaka' | 'threeq' | 'vanilla-js';
|
|
525
|
+
interface PlayerTestSuiteProps {
|
|
526
|
+
/** Default VOD ID to use (PHONT VOD ID for subtitles) */
|
|
527
|
+
defaultVodId?: string;
|
|
528
|
+
/** Default player to show */
|
|
529
|
+
defaultPlayer?: PlayerType;
|
|
530
|
+
/** Custom API endpoint (optional) */
|
|
531
|
+
apiEndpoint?: string;
|
|
532
|
+
/** Bitmovin license key (optional - can also be set via NEXT_PUBLIC_BITMOVIN_LICENSE_KEY env var) */
|
|
533
|
+
bitmovinLicenseKey?: string;
|
|
534
|
+
/** 3Q dataid (playoutId) - if provided, will be used for 3Q player instead of defaultVodId */
|
|
535
|
+
threeqDataId?: string;
|
|
536
|
+
}
|
|
537
|
+
declare function PlayerTestSuite({ defaultVodId, // Default to Pooh_Compilation
|
|
538
|
+
defaultPlayer, apiEndpoint, bitmovinLicenseKey: propBitmovinLicenseKey, threeqDataId, }: PlayerTestSuiteProps): React.JSX.Element;
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* AnimationConfigProvider
|
|
542
|
+
*
|
|
543
|
+
* Provides access to EMOTION_ANIMATIONS (function-based animation system).
|
|
544
|
+
* Now uses function-based animations instead of URL-based system.
|
|
545
|
+
*
|
|
546
|
+
* @example
|
|
547
|
+
* ```tsx
|
|
548
|
+
* <AnimationConfigProvider>
|
|
549
|
+
* <PhontSubtitles vodId="..." currentTime={...} />
|
|
550
|
+
* </AnimationConfigProvider>
|
|
551
|
+
* ```
|
|
552
|
+
*/
|
|
553
|
+
|
|
554
|
+
interface AnimationConfigContextValue {
|
|
555
|
+
emotionAnimations: typeof EMOTION_ANIMATIONS;
|
|
556
|
+
}
|
|
557
|
+
interface AnimationConfigProviderProps {
|
|
558
|
+
children: ReactNode;
|
|
559
|
+
}
|
|
560
|
+
type EmotionAnimationUrls = Record<string, string>;
|
|
561
|
+
/**
|
|
562
|
+
* Provider component for animation config (now using function-based EMOTION_ANIMATIONS)
|
|
563
|
+
*/
|
|
564
|
+
declare function AnimationConfigProvider({ children, }: AnimationConfigProviderProps): React.JSX.Element;
|
|
565
|
+
/**
|
|
566
|
+
* Hook to access animation config
|
|
567
|
+
*/
|
|
568
|
+
declare function useAnimationConfig(): AnimationConfigContextValue;
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Animation Mode Toggle Component
|
|
572
|
+
* SDK version - Switches between Word and Sentence animation modes
|
|
573
|
+
* Matches app/components/phont-controls/AnimationModeToggle.jsx
|
|
574
|
+
*/
|
|
575
|
+
|
|
576
|
+
type AnimationMode = 'Word' | 'Sentence';
|
|
577
|
+
interface AnimationModeToggleProps {
|
|
578
|
+
animationMode: AnimationMode;
|
|
579
|
+
setAnimationMode: (mode: AnimationMode) => void;
|
|
580
|
+
}
|
|
581
|
+
declare function AnimationModeToggle({ animationMode, setAnimationMode, }: AnimationModeToggleProps): React.JSX.Element;
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Phont Controls - Composition Component
|
|
585
|
+
* SDK version - Aggregates all Phont subtitle controls (GTS, Translation, Mode, Toggles, Animation Config)
|
|
586
|
+
* Matches app/components/phont-controls/PhontControls.jsx but with additional animation controls and settings panel
|
|
587
|
+
*/
|
|
588
|
+
|
|
589
|
+
interface PhontControlsProps {
|
|
590
|
+
isVisible?: boolean;
|
|
591
|
+
controlsVisible?: boolean;
|
|
592
|
+
onControlsVisibilityChange?: (visible: boolean) => void;
|
|
593
|
+
isLive?: boolean;
|
|
594
|
+
currentVideoId?: string | null;
|
|
595
|
+
gts: number;
|
|
596
|
+
setGTS: (value: number) => void;
|
|
597
|
+
subtitleLanguage?: string | null;
|
|
598
|
+
availableLanguages?: Record<string, string>;
|
|
599
|
+
currentSubtitleLanguage?: string | null;
|
|
600
|
+
handleLanguageChange?: (language: string | null) => void;
|
|
601
|
+
isTranslating?: boolean;
|
|
602
|
+
translatingToLanguage?: string | null;
|
|
603
|
+
translationProvider?: string;
|
|
604
|
+
translationModel?: string;
|
|
605
|
+
animationMode: AnimationMode;
|
|
606
|
+
setAnimationMode: (mode: AnimationMode) => void;
|
|
607
|
+
toggles: boolean[];
|
|
608
|
+
handleToggle: (index: number) => void;
|
|
609
|
+
customAnimationUrl?: string;
|
|
610
|
+
setCustomAnimationUrl?: (url: string) => void;
|
|
611
|
+
emotionMappings?: Partial<EmotionAnimationUrls>;
|
|
612
|
+
setEmotionMappings?: (mappings: Partial<EmotionAnimationUrls>) => void;
|
|
613
|
+
showSettingsPanel?: boolean;
|
|
614
|
+
selectedPlayer?: string;
|
|
615
|
+
setSelectedPlayer?: (player: string) => void;
|
|
616
|
+
players?: Array<{
|
|
617
|
+
type: string;
|
|
618
|
+
name: string;
|
|
619
|
+
}>;
|
|
620
|
+
vodId?: string;
|
|
621
|
+
setVodId?: (vodId: string) => void;
|
|
622
|
+
vods?: Array<{
|
|
623
|
+
_id: string;
|
|
624
|
+
name?: string;
|
|
625
|
+
}>;
|
|
626
|
+
onLogout?: () => void;
|
|
627
|
+
username?: string | null;
|
|
628
|
+
}
|
|
629
|
+
declare function PhontControls({ isVisible, controlsVisible: externalControlsVisible, onControlsVisibilityChange, isLive, currentVideoId, gts, setGTS, subtitleLanguage, availableLanguages, currentSubtitleLanguage, handleLanguageChange, isTranslating, translatingToLanguage, translationProvider, translationModel, animationMode, setAnimationMode, toggles, handleToggle, customAnimationUrl, setCustomAnimationUrl, emotionMappings, setEmotionMappings, showSettingsPanel, selectedPlayer, setSelectedPlayer, players, vodId, setVodId, vods, onLogout, username, }: PhontControlsProps): React.JSX.Element | null;
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* GTS (Global Tone & Style) Slider Component
|
|
633
|
+
* SDK version - Controls emotion threshold and expressiveness (max expression)
|
|
634
|
+
* Matches app/components/phont-controls/GTSSlider.jsx
|
|
635
|
+
*/
|
|
636
|
+
|
|
637
|
+
interface GTSSliderProps {
|
|
638
|
+
gts: number;
|
|
639
|
+
setGTS: (value: number) => void;
|
|
640
|
+
threshold: number;
|
|
641
|
+
maxExpression: number;
|
|
642
|
+
}
|
|
643
|
+
declare function GTSSlider({ gts, setGTS, threshold, maxExpression }: GTSSliderProps): React.JSX.Element;
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Translation Dropdown Component
|
|
647
|
+
* SDK version - Allows users to switch subtitle language (VOD only)
|
|
648
|
+
* Matches app/components/phont-controls/TranslationDropdown.jsx
|
|
649
|
+
*/
|
|
650
|
+
|
|
651
|
+
interface TranslationDropdownProps {
|
|
652
|
+
subtitleLanguage: string | null;
|
|
653
|
+
availableLanguages: Record<string, string>;
|
|
654
|
+
currentSubtitleLanguage: string | null;
|
|
655
|
+
onLanguageChange: (language: string | null) => void;
|
|
656
|
+
isTranslating?: boolean;
|
|
657
|
+
translatingToLanguage?: string | null;
|
|
658
|
+
translationProvider?: string;
|
|
659
|
+
translationModel?: string;
|
|
660
|
+
}
|
|
661
|
+
declare function TranslationDropdown({ subtitleLanguage, availableLanguages, currentSubtitleLanguage, onLanguageChange, isTranslating, translatingToLanguage, translationProvider, translationModel, }: TranslationDropdownProps): React.JSX.Element;
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Reusable Toggle Switch Component
|
|
665
|
+
* SDK version - Used for Speaker, Closed Captions, and other binary settings
|
|
666
|
+
* Matches app/components/phont-controls/ToggleSwitch.jsx
|
|
667
|
+
*/
|
|
668
|
+
|
|
669
|
+
interface ToggleSwitchProps {
|
|
670
|
+
isOn: boolean;
|
|
671
|
+
label: string;
|
|
672
|
+
onToggle: () => void;
|
|
673
|
+
}
|
|
674
|
+
declare function ToggleSwitch({ isOn, label, onToggle }: ToggleSwitchProps): React.JSX.Element;
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* Animation URL Config Component
|
|
678
|
+
* Allows users to configure custom animation URLs and emotion mappings
|
|
679
|
+
*/
|
|
680
|
+
|
|
681
|
+
interface AnimationUrlConfigProps {
|
|
682
|
+
customAnimationUrl: string;
|
|
683
|
+
setCustomAnimationUrl: (url: string) => void;
|
|
684
|
+
emotionMappings: Partial<EmotionAnimationUrls>;
|
|
685
|
+
setEmotionMappings: (mappings: Partial<EmotionAnimationUrls>) => void;
|
|
686
|
+
}
|
|
687
|
+
declare function AnimationUrlConfig({ customAnimationUrl, setCustomAnimationUrl, emotionMappings, setEmotionMappings, }: AnimationUrlConfigProps): React.JSX.Element;
|
|
688
|
+
|
|
689
|
+
/**
|
|
690
|
+
* React Client Factory
|
|
691
|
+
*
|
|
692
|
+
* Creates a PhontClient instance for use in React components
|
|
693
|
+
*/
|
|
694
|
+
|
|
695
|
+
declare function createPhontClient(config: PhontClientConfig): PhontClient;
|
|
696
|
+
|
|
697
|
+
export { AnimationConfigProvider, type AnimationConfigProviderProps, type AnimationMode, AnimationModeToggle, type AnimationModeToggleProps, AnimationUrlConfig, type AnimationUrlConfigProps, type BitmovinPlayer, BitmovinPlayerAdapter, type EmotionAnimationUrls, GTSSlider, type GTSSliderProps, HTML5VideoAdapter, type PhontClientConfig, PhontControls, type PhontControlsProps, PhontSubtitles, type PhontSubtitlesProps, PhontVideoPlayer, type PhontVideoPlayerProps, type PlayerAdapter, PlayerTestSuite, type PlayerTestSuiteProps, type PlayerType, SDKAuth, type SDKAuthProps, type SDKAuthState, type ShakaPlayer, ShakaPlayerAdapter, SoundbiteContainer, type ThreeQPlayer, ThreeQPlayerAdapter, ToggleSwitch, type ToggleSwitchProps, TranslationDropdown, type TranslationDropdownProps, type UsePlayerSyncOptions, type UsePlayerSyncResult, type UseSDKAnimationOptions, type UseVideoPlayerOptions, type VideoJSPlayer, VideoJSPlayerAdapter, createPhontClient, useAnimationConfig, usePlayerSync, useSDKAnimation, useSDKAuth, useVideoPlayer };
|