@mottosports/motto-video-player 1.0.1-rc.12 → 1.0.1-rc.5
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/README.md +161 -158
- package/dist/index.d.mts +54 -11
- package/dist/index.d.ts +54 -11
- package/dist/index.js +536 -245
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +500 -218
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Motto Video Player
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A modern, feature-rich video player built on top of Shaka Player with React support.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -17,217 +17,220 @@ React video player component for the Motto platform, powered by Shaka Player wit
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
npm install @motto
|
|
20
|
+
npm install @motto/video-player
|
|
21
|
+
# or
|
|
22
|
+
yarn add @motto/video-player
|
|
23
|
+
# or
|
|
24
|
+
pnpm add @motto/video-player
|
|
21
25
|
```
|
|
22
26
|
|
|
23
|
-
##
|
|
27
|
+
## Basic Usage
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
```tsx
|
|
30
|
+
import { Player } from '@motto/video-player';
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
function MyVideoPlayer() {
|
|
33
|
+
return (
|
|
34
|
+
<Player
|
|
35
|
+
src="https://example.com/video.m3u8"
|
|
36
|
+
autoPlay={false}
|
|
37
|
+
controls={true}
|
|
38
|
+
width={800}
|
|
39
|
+
height={450}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Next.js Usage (SSR Support)
|
|
46
|
+
|
|
47
|
+
If you're using Next.js, you need to handle server-side rendering (SSR) since Shaka Player requires browser APIs. Here are three approaches:
|
|
48
|
+
|
|
49
|
+
### Option 1: Using next/dynamic (Recommended)
|
|
29
50
|
|
|
30
|
-
|
|
51
|
+
```tsx
|
|
52
|
+
import dynamic from 'next/dynamic';
|
|
31
53
|
|
|
32
|
-
|
|
54
|
+
const MottoPlayer = dynamic(
|
|
55
|
+
() => import('@motto/video-player').then((mod) => ({ default: mod.Player })),
|
|
56
|
+
{
|
|
57
|
+
ssr: false,
|
|
58
|
+
loading: () => <div>Loading player...</div>
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
function MyVideoPage() {
|
|
33
63
|
return (
|
|
34
|
-
<
|
|
35
|
-
<
|
|
36
|
-
|
|
64
|
+
<div>
|
|
65
|
+
<h1>My Video</h1>
|
|
66
|
+
<MottoPlayer
|
|
67
|
+
src="https://example.com/video.m3u8"
|
|
68
|
+
autoPlay={false}
|
|
69
|
+
controls={true}
|
|
70
|
+
width={800}
|
|
71
|
+
height={450}
|
|
72
|
+
/>
|
|
73
|
+
</div>
|
|
37
74
|
);
|
|
38
75
|
}
|
|
39
76
|
```
|
|
40
77
|
|
|
41
|
-
###
|
|
42
|
-
|
|
43
|
-
#### VideoPlayer (Bare Component)
|
|
44
|
-
For direct stream URL playback:
|
|
78
|
+
### Option 2: Using the built-in ClientOnlyPlayer
|
|
45
79
|
|
|
46
|
-
```
|
|
47
|
-
import {
|
|
80
|
+
```tsx
|
|
81
|
+
import { ClientOnlyPlayer } from '@motto/video-player';
|
|
48
82
|
|
|
49
|
-
function
|
|
83
|
+
function MyVideoPage() {
|
|
50
84
|
return (
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
85
|
+
<div>
|
|
86
|
+
<h1>My Video</h1>
|
|
87
|
+
<ClientOnlyPlayer
|
|
88
|
+
src="https://example.com/video.m3u8"
|
|
89
|
+
autoPlay={false}
|
|
90
|
+
controls={true}
|
|
91
|
+
width={800}
|
|
92
|
+
height={450}
|
|
93
|
+
/>
|
|
94
|
+
</div>
|
|
58
95
|
);
|
|
59
96
|
}
|
|
60
97
|
```
|
|
61
98
|
|
|
62
|
-
|
|
63
|
-
|
|
99
|
+
### Option 3: Using useEffect for client-side only rendering
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import { Player } from '@motto/video-player';
|
|
103
|
+
import { useEffect, useState } from 'react';
|
|
64
104
|
|
|
65
|
-
|
|
66
|
-
|
|
105
|
+
function MyVideoPage() {
|
|
106
|
+
const [isClient, setIsClient] = useState(false);
|
|
107
|
+
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
setIsClient(true);
|
|
110
|
+
}, []);
|
|
111
|
+
|
|
112
|
+
if (!isClient) {
|
|
113
|
+
return <div>Loading player...</div>;
|
|
114
|
+
}
|
|
67
115
|
|
|
68
|
-
function MyPlayer() {
|
|
69
116
|
return (
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
/>
|
|
117
|
+
<div>
|
|
118
|
+
<h1>My Video</h1>
|
|
119
|
+
<Player
|
|
120
|
+
src="https://example.com/video.m3u8"
|
|
121
|
+
autoPlay={false}
|
|
122
|
+
controls={true}
|
|
123
|
+
width={800}
|
|
124
|
+
height={450}
|
|
125
|
+
/>
|
|
126
|
+
</div>
|
|
81
127
|
);
|
|
82
128
|
}
|
|
83
129
|
```
|
|
84
130
|
|
|
85
|
-
##
|
|
131
|
+
## Player Props
|
|
132
|
+
|
|
133
|
+
The player accepts the following props:
|
|
86
134
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
135
|
+
- `src` (string, required): URL of the video manifest (HLS, DASH, etc.)
|
|
136
|
+
- `autoPlay` (boolean, default: false): Whether to start playing automatically
|
|
137
|
+
- `controls` (boolean, default: true): Whether to show player controls
|
|
138
|
+
- `width` (number): Fixed width in pixels
|
|
139
|
+
- `height` (number): Fixed height in pixels
|
|
140
|
+
- `aspectRatio` (number, default: 16/9): Aspect ratio for responsive sizing
|
|
141
|
+
- `poster` (string): URL of poster image to show before video loads
|
|
142
|
+
- `muted` (boolean, default: false): Whether to start muted
|
|
143
|
+
- `loop` (boolean, default: false): Whether to loop the video
|
|
95
144
|
|
|
96
145
|
## Advanced Configuration
|
|
97
146
|
|
|
98
|
-
###
|
|
99
|
-
|
|
100
|
-
```
|
|
101
|
-
<
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
retry: 3,
|
|
108
|
-
retryDelay: (attemptIndex) => Math.min(1000 * 2 ** attemptIndex, 30000)
|
|
147
|
+
### Quality Control
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
<Player
|
|
151
|
+
src="https://example.com/video.m3u8"
|
|
152
|
+
qualityConfig={{
|
|
153
|
+
enableAutoQuality: true,
|
|
154
|
+
preferredVideoHeight: 720,
|
|
155
|
+
preferredAudioLanguage: 'en'
|
|
109
156
|
}}
|
|
110
157
|
/>
|
|
111
158
|
```
|
|
112
159
|
|
|
113
|
-
###
|
|
160
|
+
### DRM Configuration
|
|
114
161
|
|
|
115
|
-
```
|
|
116
|
-
<
|
|
117
|
-
src="
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
162
|
+
```tsx
|
|
163
|
+
<Player
|
|
164
|
+
src="https://example.com/protected-video.mpd"
|
|
165
|
+
drmConfig={{
|
|
166
|
+
servers: {
|
|
167
|
+
'com.widevine.alpha': 'https://license-server.com/widevine',
|
|
168
|
+
'com.microsoft.playready': 'https://license-server.com/playready'
|
|
169
|
+
}
|
|
123
170
|
}}
|
|
124
|
-
onSkipBack={(newTime) => console.log('Skipped to:', newTime)}
|
|
125
|
-
onSkipForward={(newTime) => console.log('Skipped to:', newTime)}
|
|
126
171
|
/>
|
|
127
172
|
```
|
|
128
173
|
|
|
129
|
-
###
|
|
130
|
-
|
|
131
|
-
```jsx
|
|
132
|
-
// Default responsive 16:9
|
|
133
|
-
<VideoPlayer src="..." />
|
|
174
|
+
### Mux Analytics
|
|
134
175
|
|
|
135
|
-
|
|
136
|
-
<
|
|
137
|
-
|
|
138
|
-
// Fixed dimensions
|
|
139
|
-
<VideoPlayer src="..." width={800} height={450} />
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### Analytics Integration
|
|
143
|
-
|
|
144
|
-
```jsx
|
|
145
|
-
<VideoPlayer
|
|
146
|
-
src="..."
|
|
176
|
+
```tsx
|
|
177
|
+
<Player
|
|
178
|
+
src="https://example.com/video.m3u8"
|
|
147
179
|
muxConfig={{
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
video_id: 'video-123',
|
|
153
|
-
player_name: 'Web Player',
|
|
154
|
-
viewer_user_id: 'user-456'
|
|
180
|
+
envKey: 'your-mux-env-key',
|
|
181
|
+
metadata: {
|
|
182
|
+
video_title: 'My Video',
|
|
183
|
+
viewer_user_id: 'user123'
|
|
155
184
|
}
|
|
156
185
|
}}
|
|
157
|
-
onMuxReady={(monitor) => console.log('Mux ready')}
|
|
158
186
|
/>
|
|
159
187
|
```
|
|
160
188
|
|
|
161
|
-
##
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
muxConfig?: MuxConfig; // Mux analytics configuration
|
|
175
|
-
onPlay?: () => void; // Play event callback
|
|
176
|
-
onPause?: () => void; // Pause event callback
|
|
177
|
-
onError?: (error: any) => void; // Error event callback
|
|
178
|
-
// ... more props
|
|
179
|
-
}
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### Video Props
|
|
183
|
-
|
|
184
|
-
```typescript
|
|
185
|
-
interface VideoProps extends Omit<VideoPlayerProps, 'src'> {
|
|
186
|
-
videoId?: string; // Video ID for data fetching
|
|
187
|
-
publicKey?: string; // Public key for API authentication
|
|
188
|
-
videoData?: VideoData; // Pre-loaded video data
|
|
189
|
-
refetchInterval?: number; // Background refetch interval (ms)
|
|
190
|
-
queryOptions?: QueryOptions; // TanStack Query configuration
|
|
191
|
-
events?: {
|
|
192
|
-
onVideoData?: (video: VideoData) => void;
|
|
193
|
-
onEmptyPlaylists?: () => void;
|
|
194
|
-
onError?: (error: Error) => void;
|
|
195
|
-
// ... player events
|
|
196
|
-
};
|
|
197
|
-
}
|
|
189
|
+
## Event Handling
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
<Player
|
|
193
|
+
src="https://example.com/video.m3u8"
|
|
194
|
+
events={{
|
|
195
|
+
onPlay: () => console.log('Video started playing'),
|
|
196
|
+
onPause: () => console.log('Video paused'),
|
|
197
|
+
onEnded: () => console.log('Video ended'),
|
|
198
|
+
onError: (error) => console.error('Playback error:', error),
|
|
199
|
+
onQualityChange: (quality) => console.log('Quality changed:', quality)
|
|
200
|
+
}}
|
|
201
|
+
/>
|
|
198
202
|
```
|
|
199
203
|
|
|
200
|
-
##
|
|
204
|
+
## Responsive Design
|
|
201
205
|
|
|
202
|
-
|
|
203
|
-
- **Automatic Caching**: Videos are cached with configurable stale time
|
|
204
|
-
- **Background Refetching**: Data stays fresh with background updates
|
|
205
|
-
- **Request Deduplication**: Identical requests are automatically deduplicated
|
|
206
|
-
- **Garbage Collection**: Memory-efficient cleanup of unused cache entries
|
|
206
|
+
For responsive video players, omit the `width` and `height` props and optionally set an `aspectRatio`:
|
|
207
207
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
-
|
|
208
|
+
```tsx
|
|
209
|
+
<Player
|
|
210
|
+
src="https://example.com/video.m3u8"
|
|
211
|
+
aspectRatio={16/9}
|
|
212
|
+
containerClassName="w-full max-w-4xl"
|
|
213
|
+
/>
|
|
214
|
+
```
|
|
213
215
|
|
|
214
|
-
##
|
|
216
|
+
## Live Streaming
|
|
215
217
|
|
|
216
|
-
|
|
218
|
+
The player automatically detects live streams and shows appropriate UI:
|
|
217
219
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
-
|
|
221
|
-
-
|
|
222
|
-
|
|
220
|
+
```tsx
|
|
221
|
+
<Player
|
|
222
|
+
src="https://example.com/live-stream.m3u8"
|
|
223
|
+
streamStartDate={new Date('2024-01-01T12:00:00Z')} // Optional: for absolute time display
|
|
224
|
+
/>
|
|
225
|
+
```
|
|
223
226
|
|
|
224
|
-
##
|
|
227
|
+
## Browser Support
|
|
225
228
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
229
|
+
- Chrome 80+
|
|
230
|
+
- Firefox 75+
|
|
231
|
+
- Safari 13+
|
|
232
|
+
- Edge 80+
|
|
230
233
|
|
|
231
234
|
## License
|
|
232
235
|
|
|
233
|
-
|
|
236
|
+
MIT
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { HTMLAttributes } from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Unified events interface for both Player and Video wrapper
|
|
@@ -225,7 +225,17 @@ interface PlayerProps extends Omit<HTMLAttributes<HTMLVideoElement>, 'src' | 'on
|
|
|
225
225
|
* Event callbacks
|
|
226
226
|
*/
|
|
227
227
|
events?: PlayerEvents;
|
|
228
|
+
/**
|
|
229
|
+
* CSS class name for the container element
|
|
230
|
+
*/
|
|
228
231
|
containerClassName?: string;
|
|
232
|
+
/**
|
|
233
|
+
* Optional manual override for stream start time
|
|
234
|
+
* If not provided, the player will attempt to auto-detect the stream start time
|
|
235
|
+
* from the manifest for live streams. When provided, shows elapsed time since
|
|
236
|
+
* stream started instead of the current playback position.
|
|
237
|
+
*/
|
|
238
|
+
streamStartDate?: Date;
|
|
229
239
|
}
|
|
230
240
|
/**
|
|
231
241
|
* Mux Analytics type definitions
|
|
@@ -320,7 +330,13 @@ interface MuxAnalyticsConfig {
|
|
|
320
330
|
metadata?: MuxMetadata;
|
|
321
331
|
}
|
|
322
332
|
|
|
323
|
-
declare const Player:
|
|
333
|
+
declare const Player: React__default.ForwardRefExoticComponent<PlayerProps & React__default.RefAttributes<HTMLVideoElement>>;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Client-only wrapper for the Player component to prevent SSR issues.
|
|
337
|
+
* This component only renders the Player on the client side after hydration.
|
|
338
|
+
*/
|
|
339
|
+
declare const ClientOnlyPlayer: React__default.ForwardRefExoticComponent<PlayerProps & React__default.RefAttributes<HTMLVideoElement>>;
|
|
324
340
|
|
|
325
341
|
interface VideoData {
|
|
326
342
|
id: string;
|
|
@@ -342,6 +358,22 @@ interface VideoListItem {
|
|
|
342
358
|
}>;
|
|
343
359
|
error?: string;
|
|
344
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* Fetches video data from the Motto Streaming API
|
|
363
|
+
* @param videoId - The ID of the video to fetch
|
|
364
|
+
* @param publicKey - The public key for authentication
|
|
365
|
+
* @param mottoToken - Optional motto token for authenticated requests
|
|
366
|
+
* @returns Promise<VideoData> - The video data
|
|
367
|
+
*/
|
|
368
|
+
declare const fetchVideoData: (videoId: string, publicKey: string, mottoToken?: string) => Promise<VideoData>;
|
|
369
|
+
/**
|
|
370
|
+
* Fetches multiple videos data from the Motto Streaming API
|
|
371
|
+
* @param publicKey - The public key for authentication
|
|
372
|
+
* @param videoIds - Array of video IDs to fetch
|
|
373
|
+
* @param mottoToken - Optional motto token for authenticated requests
|
|
374
|
+
* @returns Promise<VideoListItem[]> - Array of video data
|
|
375
|
+
*/
|
|
376
|
+
declare function fetchVideosList(publicKey: string, videoIds: string[], mottoToken?: string, skip?: number, limit?: number): Promise<VideoListItem[]>;
|
|
345
377
|
|
|
346
378
|
interface EventData {
|
|
347
379
|
id: string;
|
|
@@ -357,6 +389,7 @@ declare enum EventsSortDirection {
|
|
|
357
389
|
ASC = "asc",
|
|
358
390
|
DESC = "desc"
|
|
359
391
|
}
|
|
392
|
+
declare function fetchEventData(publicKey: string, eventId: string, unused?: any, filter?: string, order?: EventsSortDirection, locale?: string): Promise<EventData>;
|
|
360
393
|
|
|
361
394
|
interface CreativeWorkData {
|
|
362
395
|
id: string;
|
|
@@ -372,6 +405,7 @@ declare enum CreativeWorksSortDirection {
|
|
|
372
405
|
ASC = "asc",
|
|
373
406
|
DESC = "desc"
|
|
374
407
|
}
|
|
408
|
+
declare function fetchCreativeWorkData(publicKey: string, creativeWorkId: string, unused?: any, filter?: string, order?: CreativeWorksSortDirection, locale?: string): Promise<CreativeWorkData>;
|
|
375
409
|
|
|
376
410
|
interface VideoProps extends Omit<PlayerProps, 'src'> {
|
|
377
411
|
videoId?: string;
|
|
@@ -392,7 +426,7 @@ interface VideoProps extends Omit<PlayerProps, 'src'> {
|
|
|
392
426
|
onCanPlay?: () => void;
|
|
393
427
|
onPlayerReady?: () => void;
|
|
394
428
|
};
|
|
395
|
-
children?:
|
|
429
|
+
children?: React__default.ReactNode;
|
|
396
430
|
className?: string;
|
|
397
431
|
queryOptions?: {
|
|
398
432
|
enabled?: boolean;
|
|
@@ -402,7 +436,7 @@ interface VideoProps extends Omit<PlayerProps, 'src'> {
|
|
|
402
436
|
retryDelay?: number;
|
|
403
437
|
};
|
|
404
438
|
}
|
|
405
|
-
declare const Video:
|
|
439
|
+
declare const Video: React__default.FC<VideoProps>;
|
|
406
440
|
|
|
407
441
|
interface EventProps extends Omit<PlayerProps, 'src'> {
|
|
408
442
|
publicKey: string;
|
|
@@ -440,7 +474,7 @@ interface EventProps extends Omit<PlayerProps, 'src'> {
|
|
|
440
474
|
retryDelay?: number;
|
|
441
475
|
};
|
|
442
476
|
}
|
|
443
|
-
declare const Event:
|
|
477
|
+
declare const Event: React__default.FC<EventProps>;
|
|
444
478
|
|
|
445
479
|
interface CreativeWorkProps extends Omit<PlayerProps, 'src'> {
|
|
446
480
|
publicKey: string;
|
|
@@ -478,12 +512,21 @@ interface CreativeWorkProps extends Omit<PlayerProps, 'src'> {
|
|
|
478
512
|
retryDelay?: number;
|
|
479
513
|
};
|
|
480
514
|
}
|
|
481
|
-
declare const CreativeWork:
|
|
515
|
+
declare const CreativeWork: React__default.FC<CreativeWorkProps>;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Client-side wrapper for the Event component to prevent SSR issues
|
|
519
|
+
* This component ensures that Event is only rendered on the client-side
|
|
520
|
+
*/
|
|
521
|
+
declare const ClientSideEvent: React__default.FC<EventProps>;
|
|
482
522
|
|
|
483
|
-
declare const queryClient: QueryClient;
|
|
484
523
|
interface QueryProviderProps {
|
|
485
|
-
children:
|
|
524
|
+
children: React__default.ReactNode;
|
|
486
525
|
}
|
|
487
|
-
declare const QueryProvider:
|
|
526
|
+
declare const QueryProvider: React__default.FC<QueryProviderProps>;
|
|
527
|
+
|
|
528
|
+
declare const _default: {
|
|
529
|
+
Player: React.ForwardRefExoticComponent<PlayerProps & React.RefAttributes<HTMLVideoElement>>;
|
|
530
|
+
};
|
|
488
531
|
|
|
489
|
-
export { CreativeWork, type CreativeWorkData, type CreativeWorkProps, CreativeWorksSortDirection, Event, type EventData, type EventProps, EventsSortDirection, Player, type PlayerEvents, type PlayerProps, QueryProvider, Video, type VideoData, type VideoListItem, type VideoProps,
|
|
532
|
+
export { ClientOnlyPlayer, ClientSideEvent, CreativeWork, type CreativeWorkData, type CreativeWorkProps, CreativeWorksSortDirection, Event, type EventData, type EventProps, EventsSortDirection, type MuxAnalyticsConfig, type MuxDataUpdatePayload, type MuxErrorTranslator, type MuxMetadata, Player, type PlayerEvents, type PlayerProps, QueryProvider, type SeekbarConfig, Video, type VideoData, type VideoListItem, type VideoProps, _default as default, fetchCreativeWorkData, fetchEventData, fetchVideoData, fetchVideosList };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { HTMLAttributes } from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Unified events interface for both Player and Video wrapper
|
|
@@ -225,7 +225,17 @@ interface PlayerProps extends Omit<HTMLAttributes<HTMLVideoElement>, 'src' | 'on
|
|
|
225
225
|
* Event callbacks
|
|
226
226
|
*/
|
|
227
227
|
events?: PlayerEvents;
|
|
228
|
+
/**
|
|
229
|
+
* CSS class name for the container element
|
|
230
|
+
*/
|
|
228
231
|
containerClassName?: string;
|
|
232
|
+
/**
|
|
233
|
+
* Optional manual override for stream start time
|
|
234
|
+
* If not provided, the player will attempt to auto-detect the stream start time
|
|
235
|
+
* from the manifest for live streams. When provided, shows elapsed time since
|
|
236
|
+
* stream started instead of the current playback position.
|
|
237
|
+
*/
|
|
238
|
+
streamStartDate?: Date;
|
|
229
239
|
}
|
|
230
240
|
/**
|
|
231
241
|
* Mux Analytics type definitions
|
|
@@ -320,7 +330,13 @@ interface MuxAnalyticsConfig {
|
|
|
320
330
|
metadata?: MuxMetadata;
|
|
321
331
|
}
|
|
322
332
|
|
|
323
|
-
declare const Player:
|
|
333
|
+
declare const Player: React__default.ForwardRefExoticComponent<PlayerProps & React__default.RefAttributes<HTMLVideoElement>>;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Client-only wrapper for the Player component to prevent SSR issues.
|
|
337
|
+
* This component only renders the Player on the client side after hydration.
|
|
338
|
+
*/
|
|
339
|
+
declare const ClientOnlyPlayer: React__default.ForwardRefExoticComponent<PlayerProps & React__default.RefAttributes<HTMLVideoElement>>;
|
|
324
340
|
|
|
325
341
|
interface VideoData {
|
|
326
342
|
id: string;
|
|
@@ -342,6 +358,22 @@ interface VideoListItem {
|
|
|
342
358
|
}>;
|
|
343
359
|
error?: string;
|
|
344
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* Fetches video data from the Motto Streaming API
|
|
363
|
+
* @param videoId - The ID of the video to fetch
|
|
364
|
+
* @param publicKey - The public key for authentication
|
|
365
|
+
* @param mottoToken - Optional motto token for authenticated requests
|
|
366
|
+
* @returns Promise<VideoData> - The video data
|
|
367
|
+
*/
|
|
368
|
+
declare const fetchVideoData: (videoId: string, publicKey: string, mottoToken?: string) => Promise<VideoData>;
|
|
369
|
+
/**
|
|
370
|
+
* Fetches multiple videos data from the Motto Streaming API
|
|
371
|
+
* @param publicKey - The public key for authentication
|
|
372
|
+
* @param videoIds - Array of video IDs to fetch
|
|
373
|
+
* @param mottoToken - Optional motto token for authenticated requests
|
|
374
|
+
* @returns Promise<VideoListItem[]> - Array of video data
|
|
375
|
+
*/
|
|
376
|
+
declare function fetchVideosList(publicKey: string, videoIds: string[], mottoToken?: string, skip?: number, limit?: number): Promise<VideoListItem[]>;
|
|
345
377
|
|
|
346
378
|
interface EventData {
|
|
347
379
|
id: string;
|
|
@@ -357,6 +389,7 @@ declare enum EventsSortDirection {
|
|
|
357
389
|
ASC = "asc",
|
|
358
390
|
DESC = "desc"
|
|
359
391
|
}
|
|
392
|
+
declare function fetchEventData(publicKey: string, eventId: string, unused?: any, filter?: string, order?: EventsSortDirection, locale?: string): Promise<EventData>;
|
|
360
393
|
|
|
361
394
|
interface CreativeWorkData {
|
|
362
395
|
id: string;
|
|
@@ -372,6 +405,7 @@ declare enum CreativeWorksSortDirection {
|
|
|
372
405
|
ASC = "asc",
|
|
373
406
|
DESC = "desc"
|
|
374
407
|
}
|
|
408
|
+
declare function fetchCreativeWorkData(publicKey: string, creativeWorkId: string, unused?: any, filter?: string, order?: CreativeWorksSortDirection, locale?: string): Promise<CreativeWorkData>;
|
|
375
409
|
|
|
376
410
|
interface VideoProps extends Omit<PlayerProps, 'src'> {
|
|
377
411
|
videoId?: string;
|
|
@@ -392,7 +426,7 @@ interface VideoProps extends Omit<PlayerProps, 'src'> {
|
|
|
392
426
|
onCanPlay?: () => void;
|
|
393
427
|
onPlayerReady?: () => void;
|
|
394
428
|
};
|
|
395
|
-
children?:
|
|
429
|
+
children?: React__default.ReactNode;
|
|
396
430
|
className?: string;
|
|
397
431
|
queryOptions?: {
|
|
398
432
|
enabled?: boolean;
|
|
@@ -402,7 +436,7 @@ interface VideoProps extends Omit<PlayerProps, 'src'> {
|
|
|
402
436
|
retryDelay?: number;
|
|
403
437
|
};
|
|
404
438
|
}
|
|
405
|
-
declare const Video:
|
|
439
|
+
declare const Video: React__default.FC<VideoProps>;
|
|
406
440
|
|
|
407
441
|
interface EventProps extends Omit<PlayerProps, 'src'> {
|
|
408
442
|
publicKey: string;
|
|
@@ -440,7 +474,7 @@ interface EventProps extends Omit<PlayerProps, 'src'> {
|
|
|
440
474
|
retryDelay?: number;
|
|
441
475
|
};
|
|
442
476
|
}
|
|
443
|
-
declare const Event:
|
|
477
|
+
declare const Event: React__default.FC<EventProps>;
|
|
444
478
|
|
|
445
479
|
interface CreativeWorkProps extends Omit<PlayerProps, 'src'> {
|
|
446
480
|
publicKey: string;
|
|
@@ -478,12 +512,21 @@ interface CreativeWorkProps extends Omit<PlayerProps, 'src'> {
|
|
|
478
512
|
retryDelay?: number;
|
|
479
513
|
};
|
|
480
514
|
}
|
|
481
|
-
declare const CreativeWork:
|
|
515
|
+
declare const CreativeWork: React__default.FC<CreativeWorkProps>;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Client-side wrapper for the Event component to prevent SSR issues
|
|
519
|
+
* This component ensures that Event is only rendered on the client-side
|
|
520
|
+
*/
|
|
521
|
+
declare const ClientSideEvent: React__default.FC<EventProps>;
|
|
482
522
|
|
|
483
|
-
declare const queryClient: QueryClient;
|
|
484
523
|
interface QueryProviderProps {
|
|
485
|
-
children:
|
|
524
|
+
children: React__default.ReactNode;
|
|
486
525
|
}
|
|
487
|
-
declare const QueryProvider:
|
|
526
|
+
declare const QueryProvider: React__default.FC<QueryProviderProps>;
|
|
527
|
+
|
|
528
|
+
declare const _default: {
|
|
529
|
+
Player: React.ForwardRefExoticComponent<PlayerProps & React.RefAttributes<HTMLVideoElement>>;
|
|
530
|
+
};
|
|
488
531
|
|
|
489
|
-
export { CreativeWork, type CreativeWorkData, type CreativeWorkProps, CreativeWorksSortDirection, Event, type EventData, type EventProps, EventsSortDirection, Player, type PlayerEvents, type PlayerProps, QueryProvider, Video, type VideoData, type VideoListItem, type VideoProps,
|
|
532
|
+
export { ClientOnlyPlayer, ClientSideEvent, CreativeWork, type CreativeWorkData, type CreativeWorkProps, CreativeWorksSortDirection, Event, type EventData, type EventProps, EventsSortDirection, type MuxAnalyticsConfig, type MuxDataUpdatePayload, type MuxErrorTranslator, type MuxMetadata, Player, type PlayerEvents, type PlayerProps, QueryProvider, type SeekbarConfig, Video, type VideoData, type VideoListItem, type VideoProps, _default as default, fetchCreativeWorkData, fetchEventData, fetchVideoData, fetchVideosList };
|