@mottosports/motto-video-player 1.0.1-rc.2 → 1.0.1-rc.21

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 CHANGED
@@ -8,6 +8,7 @@ React video player component for the Motto platform, powered by Shaka Player wit
8
8
  - 🔄 **TanStack Query Integration**: Advanced caching, background refetching, and error handling
9
9
  - 📱 **Responsive Design**: Automatic aspect ratio handling and mobile-friendly controls
10
10
  - 🎮 **Skip Controls**: Built-in skip back/forward buttons with customizable durations
11
+ - ⌨️ **Keyboard Controls**: Desktop keyboard shortcuts (arrows for skip, spacebar for play/pause)
11
12
  - 🎯 **Quality Control**: Automatic quality selection and manual quality switching
12
13
  - 📊 **Analytics**: Built-in Mux analytics support
13
14
  - 🖥️ **Chromecast Support**: Cast videos to compatible devices
@@ -20,108 +21,6 @@ React video player component for the Motto platform, powered by Shaka Player wit
20
21
  npm install @motto-ui-components/motto-video-player @tanstack/react-query
21
22
  ```
22
23
 
23
- ## Next.js SSR Compatibility
24
-
25
- This component is now fully compatible with Next.js Server-Side Rendering (SSR). The component automatically detects when it's running in a server environment and gracefully handles browser-only APIs.
26
-
27
- ### Basic Usage in Next.js
28
-
29
- For SSR compatibility, use the `ClientSideEvent` component which only renders on the client side:
30
-
31
- ```tsx
32
- import { ClientSideEvent } from '@mottosports/motto-video-player';
33
-
34
- export default function MyPage() {
35
- return (
36
- <ClientSideEvent
37
- publicKey="your-public-key"
38
- eventId="your-event-id"
39
- locale="en"
40
- />
41
- );
42
- }
43
- ```
44
-
45
- Alternatively, if you prefer to use the regular `Event` component, wrap it with SSR checks:
46
-
47
- ```tsx
48
- import { Event } from '@mottosports/motto-video-player';
49
-
50
- export default function MyPage() {
51
- return (
52
- <Event
53
- publicKey="your-public-key"
54
- eventId="your-event-id"
55
- locale="en"
56
- />
57
- );
58
- }
59
- ```
60
-
61
- ### Dynamic Imports (Alternative Approach)
62
-
63
- You can also use Next.js dynamic imports with the regular Event component:
64
-
65
- ```tsx
66
- import dynamic from 'next/dynamic';
67
-
68
- const Event = dynamic(
69
- () => import('@mottosports/motto-video-player').then(mod => ({ default: mod.Event })),
70
- {
71
- ssr: false,
72
- loading: () => <div>Loading video player...</div>
73
- }
74
- );
75
-
76
- export default function MyPage() {
77
- return (
78
- <Event
79
- publicKey="your-public-key"
80
- eventId="your-event-id"
81
- locale="en"
82
- />
83
- );
84
- }
85
- ```
86
-
87
- **Recommended Approach**: Use `ClientSideEvent` for simpler SSR handling without dynamic imports.
88
-
89
- ### App Router Usage (Next.js 13+)
90
-
91
- With App Router, you can use `ClientSideEvent` directly without 'use client' directive:
92
-
93
- ```tsx
94
- import { ClientSideEvent } from '@mottosports/motto-video-player';
95
-
96
- export default function VideoPlayer() {
97
- return (
98
- <ClientSideEvent
99
- publicKey="your-public-key"
100
- eventId="your-event-id"
101
- locale="en"
102
- />
103
- );
104
- }
105
- ```
106
-
107
- Or use the regular Event component with 'use client':
108
-
109
- ```tsx
110
- 'use client';
111
-
112
- import { Event } from '@mottosports/motto-video-player';
113
-
114
- export default function VideoPlayer() {
115
- return (
116
- <Event
117
- publicKey="your-public-key"
118
- eventId="your-event-id"
119
- locale="en"
120
- />
121
- );
122
- }
123
- ```
124
-
125
24
  ## Quick Start
126
25
 
127
26
  ### Setup QueryClient (Required for Video wrapper)
@@ -228,6 +127,16 @@ function MyPlayer() {
228
127
  />
229
128
  ```
230
129
 
130
+ ### Keyboard Controls
131
+
132
+ Desktop users can control the player using keyboard shortcuts:
133
+
134
+ - **←** Left Arrow: Skip back 15 seconds
135
+ - **→** Right Arrow: Skip forward 15 seconds
136
+ - **Space**: Play/Pause toggle
137
+
138
+ Keyboard controls are automatically enabled on desktop devices (disabled on mobile) and work when the player is focused or when no input fields are active.
139
+
231
140
  ### Responsive Sizing
232
141
 
233
142
  ```jsx
package/dist/index.d.mts CHANGED
@@ -94,11 +94,28 @@ interface SeekbarConfig {
94
94
  */
95
95
  played?: string;
96
96
  }
97
+ /**
98
+ * Icon size configuration
99
+ */
100
+ interface IconSizes {
101
+ /**
102
+ * Size for skip back/forward buttons (in pixels)
103
+ */
104
+ skipButtons?: number;
105
+ /**
106
+ * Size for the big play button (in pixels)
107
+ */
108
+ bigPlayButton?: number;
109
+ }
97
110
  interface PlayerProps extends Omit<HTMLAttributes<HTMLVideoElement>, 'src' | 'onError'> {
98
111
  /**
99
112
  * The source URL of the video (DASH, HLS, or regular MP4)
100
113
  */
101
114
  src: string;
115
+ /**
116
+ * The name of the player (used for Mux analytics. For example, 'Web' or 'Mobile App')
117
+ */
118
+ playerName?: string;
102
119
  /**
103
120
  * Whether the video should autoplay
104
121
  */
@@ -222,20 +239,14 @@ interface PlayerProps extends Omit<HTMLAttributes<HTMLVideoElement>, 'src' | 'on
222
239
  */
223
240
  seekbarConfig?: SeekbarConfig;
224
241
  /**
225
- * Event callbacks
242
+ * Icon size configuration
226
243
  */
227
- events?: PlayerEvents;
244
+ iconSizes?: IconSizes;
228
245
  /**
229
- * CSS class name for the container element
246
+ * Event callbacks
230
247
  */
248
+ events?: PlayerEvents;
231
249
  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;
239
250
  }
240
251
  /**
241
252
  * Mux Analytics type definitions
@@ -452,13 +463,6 @@ interface EventProps extends Omit<PlayerProps, 'src'> {
452
463
  }
453
464
  declare const Event: React.FC<EventProps>;
454
465
 
455
- /**
456
- * Client-side wrapper for the Event component that prevents SSR issues.
457
- * This component only renders the Event component after the client has mounted,
458
- * preventing any browser API calls during server-side rendering.
459
- */
460
- declare const ClientSideEvent: React.FC<EventProps>;
461
-
462
466
  interface CreativeWorkProps extends Omit<PlayerProps, 'src'> {
463
467
  publicKey: string;
464
468
  creativeWorkId: string;
@@ -503,4 +507,22 @@ interface QueryProviderProps {
503
507
  }
504
508
  declare const QueryProvider: React.FC<QueryProviderProps>;
505
509
 
506
- export { ClientSideEvent, 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, queryClient };
510
+ interface SkipBackIconProps {
511
+ size?: number;
512
+ className?: string;
513
+ }
514
+ declare const SkipBackIcon: React.FC<SkipBackIconProps>;
515
+
516
+ interface SkipForwardIconProps {
517
+ size?: number;
518
+ className?: string;
519
+ }
520
+ declare const SkipForwardIcon: React.FC<SkipForwardIconProps>;
521
+
522
+ interface BigPlayIconProps {
523
+ size?: number;
524
+ className?: string;
525
+ }
526
+ declare const BigPlayIcon: React.FC<BigPlayIconProps>;
527
+
528
+ export { BigPlayIcon, CreativeWork, type CreativeWorkData, type CreativeWorkProps, CreativeWorksSortDirection, Event, type EventData, type EventProps, EventsSortDirection, type IconSizes, Player, type PlayerEvents, type PlayerProps, QueryProvider, SkipBackIcon, SkipForwardIcon, Video, type VideoData, type VideoListItem, type VideoProps, queryClient };
package/dist/index.d.ts CHANGED
@@ -94,11 +94,28 @@ interface SeekbarConfig {
94
94
  */
95
95
  played?: string;
96
96
  }
97
+ /**
98
+ * Icon size configuration
99
+ */
100
+ interface IconSizes {
101
+ /**
102
+ * Size for skip back/forward buttons (in pixels)
103
+ */
104
+ skipButtons?: number;
105
+ /**
106
+ * Size for the big play button (in pixels)
107
+ */
108
+ bigPlayButton?: number;
109
+ }
97
110
  interface PlayerProps extends Omit<HTMLAttributes<HTMLVideoElement>, 'src' | 'onError'> {
98
111
  /**
99
112
  * The source URL of the video (DASH, HLS, or regular MP4)
100
113
  */
101
114
  src: string;
115
+ /**
116
+ * The name of the player (used for Mux analytics. For example, 'Web' or 'Mobile App')
117
+ */
118
+ playerName?: string;
102
119
  /**
103
120
  * Whether the video should autoplay
104
121
  */
@@ -222,20 +239,14 @@ interface PlayerProps extends Omit<HTMLAttributes<HTMLVideoElement>, 'src' | 'on
222
239
  */
223
240
  seekbarConfig?: SeekbarConfig;
224
241
  /**
225
- * Event callbacks
242
+ * Icon size configuration
226
243
  */
227
- events?: PlayerEvents;
244
+ iconSizes?: IconSizes;
228
245
  /**
229
- * CSS class name for the container element
246
+ * Event callbacks
230
247
  */
248
+ events?: PlayerEvents;
231
249
  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;
239
250
  }
240
251
  /**
241
252
  * Mux Analytics type definitions
@@ -452,13 +463,6 @@ interface EventProps extends Omit<PlayerProps, 'src'> {
452
463
  }
453
464
  declare const Event: React.FC<EventProps>;
454
465
 
455
- /**
456
- * Client-side wrapper for the Event component that prevents SSR issues.
457
- * This component only renders the Event component after the client has mounted,
458
- * preventing any browser API calls during server-side rendering.
459
- */
460
- declare const ClientSideEvent: React.FC<EventProps>;
461
-
462
466
  interface CreativeWorkProps extends Omit<PlayerProps, 'src'> {
463
467
  publicKey: string;
464
468
  creativeWorkId: string;
@@ -503,4 +507,22 @@ interface QueryProviderProps {
503
507
  }
504
508
  declare const QueryProvider: React.FC<QueryProviderProps>;
505
509
 
506
- export { ClientSideEvent, 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, queryClient };
510
+ interface SkipBackIconProps {
511
+ size?: number;
512
+ className?: string;
513
+ }
514
+ declare const SkipBackIcon: React.FC<SkipBackIconProps>;
515
+
516
+ interface SkipForwardIconProps {
517
+ size?: number;
518
+ className?: string;
519
+ }
520
+ declare const SkipForwardIcon: React.FC<SkipForwardIconProps>;
521
+
522
+ interface BigPlayIconProps {
523
+ size?: number;
524
+ className?: string;
525
+ }
526
+ declare const BigPlayIcon: React.FC<BigPlayIconProps>;
527
+
528
+ export { BigPlayIcon, CreativeWork, type CreativeWorkData, type CreativeWorkProps, CreativeWorksSortDirection, Event, type EventData, type EventProps, EventsSortDirection, type IconSizes, Player, type PlayerEvents, type PlayerProps, QueryProvider, SkipBackIcon, SkipForwardIcon, Video, type VideoData, type VideoListItem, type VideoProps, queryClient };