video-react-new 0.21.0 → 0.21.2

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/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Fixed
11
+ - **Module Resolution:** Fixed a "Module not found" error when using the package with bundlers like Webpack. The `package.json` now points to the correct distribution files (`dist/` instead of `lib/`).
12
+ - **TypeScript Support:** Resolved an issue where `npm` would fail to find type definitions (`@types/video-react-new`). The package now correctly bundles and declares its own TypeScript types.
13
+ - **React 19 Compatibility:** Removed usage of the legacy `contextTypes` API in the `Player` component, fixing a critical error when using the library with React 19.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 video-react-new
3
+ Copyright (c) 2025 video-react
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -2,89 +2,482 @@
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/video-react-new.svg)](https://badge.fury.io/js/video-react-new)
4
4
  [![Package Quality](http://npm.packagequality.com/shield/video-react-new.svg)](http://packagequality.com/#?package=video-react-new)
5
- [![codecov](https://codecov.io/gh/video-react-new/video-react-new/branch/master/graph/badge.svg)](https://codecov.io/gh/video-react-new/video-react-new)
6
5
 
7
- Video.React is a web video player built from the ground up for an HTML5 world using React library.
6
+ Video-React-New is a web video player built from the ground up for an HTML5 world using React library.
8
7
 
9
- ### ✨ The future of Video.React New
8
+ ### ✨ About Video-React-New
10
9
 
11
- Maintenance of Video.React is being taken over by [Mux](https://www.mux.com). Mux is a [video api](https://www.mux.com/video-api) for developers. The team at Mux have worked on many highly respected projects and are committed to improving video tooling for developers.
10
+ This is a maintained fork of the original [video-react](https://github.com/video-react/video-react) project, with continued support for modern React versions (React 15-19) and ongoing bug fixes. The project aims to provide a stable, feature-rich video player component for React applications.
12
11
 
13
- Video.React will remain open source, but with a higher rate of fixes and releases over time. Thanks to everyone in the community for your ongoing support.
12
+ **Key Features:**
13
+ - 🎬 HTML5 video player built specifically for React
14
+ - ⚛️ Full support for React 15, 16, 17, 18, and 19
15
+ - 📱 Responsive design that works on mobile and desktop
16
+ - 🎨 Customizable UI with SCSS/CSS
17
+ - 🔌 Plugin support for HLS, DASH and other formats
18
+ - ♿ Accessibility features with keyboard controls
19
+ - 🌐 Multiple subtitle/caption track support
20
+ - 🎛️ Playback rate control
21
+ - 📺 Fullscreen support
22
+ - 🔊 Volume control with mute toggle
14
23
 
15
24
  ## Installation
16
25
 
17
- Install `video-react-new` and **peer dependencies** via NPM
26
+ Install `video-react-new` and **peer dependencies** via NPM:
18
27
 
19
28
  ```sh
20
29
  npm install --save video-react-new react react-dom
21
30
  ```
22
31
 
23
- import css in your app or add video-react-new styles in your page
32
+ Or using Yarn:
33
+
34
+ ```sh
35
+ yarn add video-react-new react react-dom
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ### Import Styles
41
+
42
+ You need to import the CSS styles. Choose one of the following methods:
43
+
44
+ **Method 1: Import CSS directly in your JavaScript**
24
45
 
25
46
  ```jsx
26
- import '~video-react-new/dist/video-react-new.css'; // import css
47
+ import 'video-react-new/dist/video-react-new.css';
27
48
  ```
28
49
 
29
- or
50
+ **Method 2: Import SCSS (for customization)**
30
51
 
31
52
  ```scss
32
- @import '~video-react-new/styles/scss/video-react-new.scss'; // or import scss
53
+ @import '~video-react-new/styles/scss/video-react-new.scss';
33
54
  ```
34
55
 
56
+ **Method 3: Link in HTML**
57
+
58
+ ```html
59
+ <link
60
+ rel="stylesheet"
61
+ href="https://unpkg.com/video-react-new/dist/video-react-new.css"
62
+ />
63
+ ```
35
64
 
65
+ ### Basic Example
36
66
 
37
- Import the components you need, example:
67
+ Import the `Player` component and use it in your React application:
38
68
 
39
- ```js
69
+ ```jsx
40
70
  import React from 'react';
41
71
  import { Player } from 'video-react-new';
42
72
 
43
- export default props => {
73
+ export default function VideoPlayer() {
44
74
  return (
45
75
  <Player>
46
76
  <source src="https://media.w3.org/2010/05/sintel/trailer_hd.mp4" />
47
77
  </Player>
48
78
  );
49
- };
79
+ }
50
80
  ```
51
81
 
82
+ ### Advanced Example with Multiple Sources and Subtitles
83
+
84
+ ```jsx
85
+ import React from 'react';
86
+ import { Player, BigPlayButton } from 'video-react-new';
87
+
88
+ export default function AdvancedPlayer() {
89
+ return (
90
+ <Player
91
+ playsInline
92
+ poster="/assets/poster.png"
93
+ src="https://media.w3.org/2010/05/sintel/trailer_hd.mp4"
94
+ >
95
+ <source src="https://media.w3.org/2010/05/sintel/trailer_hd.mp4" />
96
+ <track
97
+ kind="captions"
98
+ src="/assets/captions.en.vtt"
99
+ srclang="en"
100
+ label="English"
101
+ default
102
+ />
103
+ <track
104
+ kind="captions"
105
+ src="/assets/captions.es.vtt"
106
+ srclang="es"
107
+ label="Spanish"
108
+ />
109
+ <BigPlayButton position="center" />
110
+ </Player>
111
+ );
112
+ }
113
+ ```
114
+
115
+ ### Controlling the Player
116
+
117
+ You can control the player programmatically using refs:
118
+
119
+ ```jsx
120
+ import React, { useRef } from 'react';
121
+ import { Player } from 'video-react-new';
122
+
123
+ export default function ControlledPlayer() {
124
+ const playerRef = useRef(null);
125
+
126
+ const handlePlay = () => {
127
+ playerRef.current.play();
128
+ };
129
+
130
+ const handlePause = () => {
131
+ playerRef.current.pause();
132
+ };
133
+
134
+ const handleSeek = (seconds) => {
135
+ playerRef.current.seek(seconds);
136
+ };
137
+
138
+ return (
139
+ <div>
140
+ <Player ref={playerRef}>
141
+ <source src="https://media.w3.org/2010/05/sintel/trailer_hd.mp4" />
142
+ </Player>
143
+ <button onClick={handlePlay}>Play</button>
144
+ <button onClick={handlePause}>Pause</button>
145
+ <button onClick={() => handleSeek(10)}>Skip to 10s</button>
146
+ </div>
147
+ );
148
+ }
149
+ ```
150
+
151
+ ### Using with State Management
152
+
153
+ ```jsx
154
+ import React, { useRef, useEffect } from 'react';
155
+ import { Player } from 'video-react-new';
156
+
157
+ export default function StatePlayer() {
158
+ const playerRef = useRef(null);
159
+
160
+ useEffect(() => {
161
+ // Subscribe to player state changes
162
+ playerRef.current.subscribeToStateChange((state, prevState) => {
163
+ console.log('Current time:', state.currentTime);
164
+ console.log('Duration:', state.duration);
165
+ console.log('Playing:', !state.paused);
166
+ });
167
+ }, []);
168
+
169
+ return (
170
+ <Player ref={playerRef}>
171
+ <source src="https://media.w3.org/2010/05/sintel/trailer_hd.mp4" />
172
+ </Player>
173
+ );
174
+ }
175
+ ```
176
+
177
+ ## Available Components
178
+
179
+ - `Player` - Main video player component
180
+ - `BigPlayButton` - Large play button overlay
181
+ - `LoadingSpinner` - Loading indicator
182
+ - `PosterImage` - Poster image component
183
+ - `ControlBar` - Player control bar
184
+ - `PlayToggle` - Play/pause button
185
+ - `ForwardControl` - Forward skip button
186
+ - `ReplayControl` - Replay/rewind button
187
+ - `FullscreenToggle` - Fullscreen button
188
+ - `ProgressControl` - Progress bar
189
+ - `SeekBar` - Seekable progress bar
190
+ - `PlaybackRateMenuButton` - Playback speed control
191
+ - `VolumeMenuButton` - Volume control
192
+ - `ClosedCaptionButton` - Closed captions toggle
193
+ - `RemainingTimeDisplay` - Remaining time display
194
+ - `CurrentTimeDisplay` - Current time display
195
+ - `DurationDisplay` - Total duration display
196
+ - `TimeDivider` - Time divider
197
+ - `Bezel` - Animated bezel for actions
198
+ - `Shortcut` - Keyboard shortcuts
199
+
200
+ ## API Documentation
201
+
202
+ ### Player Props
203
+
204
+ | Prop | Type | Default | Description |
205
+ |------|------|---------|-------------|
206
+ | `fluid` | boolean | `true` | Player size follows container width |
207
+ | `width` | number | - | Player width in pixels |
208
+ | `height` | number | - | Player height in pixels |
209
+ | `src` | string | - | Video source URL |
210
+ | `poster` | string | - | Poster image URL |
211
+ | `preload` | string | `'auto'` | Preload strategy: 'auto', 'metadata', 'none' |
212
+ | `autoPlay` | boolean | `false` | Autoplay video on load |
213
+ | `loop` | boolean | `false` | Loop video playback |
214
+ | `muted` | boolean | `false` | Mute video by default |
215
+ | `playsInline` | boolean | `false` | Play inline on mobile devices |
216
+ | `aspectRatio` | string | `'auto'` | Aspect ratio (e.g., '16:9', '4:3') |
217
+ | `startTime` | number | - | Start playback at specific time (seconds) |
218
+
219
+ ### Player Methods (via ref)
220
+
221
+ | Method | Description |
222
+ |--------|-------------|
223
+ | `play()` | Start playback |
224
+ | `pause()` | Pause playback |
225
+ | `load()` | Load video |
226
+ | `seek(time)` | Seek to specific time in seconds |
227
+ | `forward(seconds)` | Skip forward by seconds |
228
+ | `replay(seconds)` | Skip backward by seconds |
229
+ | `changeRate(rate)` | Change playback rate (0.5, 1, 1.5, 2, etc.) |
230
+ | `changeVolume(volume)` | Change volume (0 to 1) |
231
+ | `mute()` | Mute audio |
232
+ | `unmute()` | Unmute audio |
233
+ | `toggleFullscreen()` | Toggle fullscreen mode |
234
+ | `subscribeToStateChange(callback)` | Subscribe to state changes |
235
+
52
236
  ## Browser support
53
237
 
54
238
  | Browser | Windows | Mac | Linux | Android | iOS |
55
239
  | :-----: | :------: | :---: | :---: | :------: | :--------: |
56
- | Chrome | **Y** | **Y** | **Y** | **Y** | **Native** |
57
- | Firefox | **Y** | **Y** | **Y** | untested | **Native** |
58
- | Edge | **Y** | - | - | - | - |
59
- | IE 11 | untested | - | - | - | - |
60
- | Safari | - | **Y** | - | - | **Y** |
240
+ | Chrome | **Yes** | **Yes** | **Yes** | **Yes** | **Native** |
241
+ | Firefox | **Yes** | **Yes** | **Yes** | **Yes** | **Native** |
242
+ | Edge | **Yes** | **Yes** | - | - | - |
243
+ | IE 11 | Untested | - | - | - | - |
244
+ | Safari | - | **Yes** | - | - | **Yes** |
245
+
246
+ **Notes:**
247
+ - Only the latest stable version is actively tested and supported
248
+ - Video-react-new may work in older browser releases, and we accept pull requests for them
249
+ - "Native" means the browser's native video player is used on mobile
250
+ - For "Untested" browsers, community testing is welcome
251
+
252
+ ## HLS and DASH Support
253
+
254
+ For HLS (HTTP Live Streaming) playback, you can use [hls.js](https://github.com/video-dev/hls.js):
255
+
256
+ ```jsx
257
+ import React, { useRef, useEffect } from 'react';
258
+ import { Player } from 'video-react-new';
259
+ import Hls from 'hls.js';
260
+
261
+ export default function HLSPlayer() {
262
+ const playerRef = useRef(null);
263
+
264
+ useEffect(() => {
265
+ const player = playerRef.current;
266
+ if (Hls.isSupported()) {
267
+ const hls = new Hls();
268
+ hls.loadSource('https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8');
269
+ hls.attachMedia(player.video.video);
270
+ } else if (player.video.video.canPlayType('application/vnd.apple.mpegurl')) {
271
+ player.video.video.src = 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8';
272
+ }
273
+ }, []);
274
+
275
+ return (
276
+ <Player ref={playerRef}>
277
+ <source src="https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8" type="application/x-mpegURL" />
278
+ </Player>
279
+ );
280
+ }
281
+ ```
282
+
283
+ ## Keyboard Shortcuts
284
+
285
+ When the player is focused, you can use these keyboard shortcuts:
286
+
287
+ | Key | Action |
288
+ |-----|--------|
289
+ | `Space` or `K` | Play/Pause |
290
+ | `←` | Rewind 5 seconds |
291
+ | `→` | Forward 5 seconds |
292
+ | `↑` | Increase volume |
293
+ | `↓` | Decrease volume |
294
+ | `F` | Toggle fullscreen |
295
+ | `M` | Toggle mute |
296
+ | `0-9` | Jump to 0%-90% of video |
297
+ | `Home` | Jump to beginning |
298
+ | `End` | Jump to end |
299
+
300
+ ## Styling and Customization
61
301
 
62
- Please note that only the latest stable version is tested and supported. video-react-new may be usable in older releases, and we will accept pull requests for them, but they will not be frequently tested or actively supported.
302
+ The player can be styled using CSS or SCSS. All components have BEM-style class names:
63
303
 
64
- For the items marked as "untested", we do welcome volunteer testers.
304
+ ```css
305
+ /* Custom player styles */
306
+ .video-react .video-react-big-play-button {
307
+ background-color: #ff0000;
308
+ border-color: #ff0000;
309
+ }
310
+
311
+ .video-react .video-react-control-bar {
312
+ background-color: rgba(0, 0, 0, 0.7);
313
+ }
314
+
315
+ .video-react .video-react-play-progress {
316
+ background-color: #ff0000;
317
+ }
318
+ ```
319
+
320
+ For SCSS customization, you can override variables before importing:
321
+
322
+ ```scss
323
+ // Override default variables
324
+ $primary-background-color: #000;
325
+ $primary-foreground-color: #fff;
326
+ $primary-color: #ff0000;
327
+
328
+ // Import the styles
329
+ @import '~video-react-new/styles/scss/video-react-new.scss';
330
+ ```
65
331
 
66
332
  ## Development
67
333
 
68
- Run tests:
334
+ ### Setup
69
335
 
70
- ```sh
336
+ Clone the repository and install dependencies:
337
+
338
+ ```bash
339
+ git clone https://github.com/thind9xdev/video-react-new-dart.git
340
+ cd video-react-new-dart
341
+ npm install
342
+ ```
343
+
344
+ ### Run Development Server
345
+
346
+ Start the development server with hot reloading:
347
+
348
+ ```bash
349
+ npm start
350
+ ```
351
+
352
+ The documentation site will be available at `http://localhost:8000`.
353
+
354
+ ### Run Tests
355
+
356
+ Run the test suite:
357
+
358
+ ```bash
71
359
  npm test
72
360
  ```
73
361
 
74
- ### Run from local
362
+ Run tests in watch mode:
363
+
364
+ ```bash
365
+ npm run test:watch
366
+ ```
367
+
368
+ Run tests with coverage:
369
+
370
+ ```bash
371
+ npm run test:coverage
372
+ ```
373
+
374
+ ### Build
375
+
376
+ Build the library:
377
+
378
+ ```bash
379
+ npm run build
380
+ ```
381
+
382
+ Build the documentation:
75
383
 
76
384
  ```bash
77
- $ npm install
78
- $ npm start
385
+ npm run build-docs
386
+ ```
387
+
388
+ ### Linting
389
+
390
+ Run ESLint:
391
+
392
+ ```bash
393
+ npm run lint
394
+ ```
395
+
396
+ Format code with Prettier:
397
+
398
+ ```bash
399
+ npm run format-all
79
400
  ```
80
401
 
81
402
  ## Contribution
82
403
 
83
- Interested in making contribution to this project? Want to report a bug? Please read the [contribution guide](./CONTRIBUTION.md).
404
+ We welcome contributions! If you'd like to contribute to video-react-new:
405
+
406
+ 1. **Fork the repository** on GitHub
407
+ 2. **Clone your fork** locally
408
+ 3. **Create a feature branch**: `git checkout -b my-new-feature`
409
+ 4. **Make your changes** and add tests if applicable
410
+ 5. **Run tests**: `npm test`
411
+ 6. **Commit your changes**: `git commit -am 'Add some feature'`
412
+ 7. **Push to the branch**: `git push origin my-new-feature`
413
+ 8. **Submit a pull request**
414
+
415
+ For more detailed information, please read the [contribution guide](./CONTRIBUTION.md).
416
+
417
+ ### Reporting Issues
418
+
419
+ If you encounter a bug or have a feature request:
420
+
421
+ 1. Check the [issue list](https://github.com/thind9xdev/video-react-new-dart/issues) first
422
+ 2. If not already reported, create a new issue
423
+ 3. Provide as much detail as possible:
424
+ - Steps to reproduce the bug
425
+ - Expected vs actual behavior
426
+ - Browser and version
427
+ - React version
428
+ - Code examples or screenshots
429
+
430
+ ## FAQ
431
+
432
+ ### How do I customize the player appearance?
433
+
434
+ You can customize the player by overriding CSS classes or importing the SCSS and modifying variables. See the [Styling and Customization](#styling-and-customization) section.
435
+
436
+ ### Does it support HLS/DASH streaming?
437
+
438
+ Yes! You can use libraries like hls.js or dash.js with video-react-new. See the [HLS and DASH Support](#hls-and-dash-support) section.
439
+
440
+ ### Can I use this with TypeScript?
441
+
442
+ Yes, the package includes TypeScript type definitions.
443
+
444
+ ### How do I access the native video element?
445
+
446
+ Use a ref to access the player, then use `playerRef.current.video.video` to access the native HTML5 video element.
447
+
448
+ ### Does it work with Next.js?
449
+
450
+ Yes, video-react-new works with Next.js. Just make sure to import styles appropriately for your Next.js configuration.
451
+
452
+ ## License
453
+
454
+ MIT © [Video-React-New Contributors](https://github.com/thind9xdev/video-react-new-dart/graphs/contributors)
84
455
 
85
456
  ## Inspiration & Credits
86
457
 
87
- - This project is heavily inspired by [video.js](http://www.videojs.com), and most of our css styles came from [video.js's styles](https://github.com/videojs/video.js/tree/master/src/css).
88
- - The document site is built with [reactstrap](https://github.com/reactstrap/reactstrap).
89
- - All the icons came from [Google Material Icons](https://material.io/icons/)
90
- - Fonts were built by [iconmon](https://icomoon.io/).
458
+ - This project is a maintained fork of [video-react](https://github.com/video-react/video-react)
459
+ - Heavily inspired by [video.js](http://www.videojs.com)
460
+ - CSS styles adapted from [video.js's styles](https://github.com/videojs/video.js/tree/master/src/css)
461
+ - Documentation site built with [reactstrap](https://github.com/reactstrap/reactstrap)
462
+ - Icons from [Google Material Icons](https://material.io/icons/)
463
+ - Fonts built with [IcoMoon](https://icomoon.io/)
464
+
465
+ ## Links
466
+
467
+ - [GitHub Repository](https://github.com/thind9xdev/video-react-new-dart)
468
+ - [NPM Package](https://www.npmjs.com/package/video-react-new)
469
+ - [Issue Tracker](https://github.com/thind9xdev/video-react-new-dart/issues)
470
+ - [Changelog](./CHANGELOG.md)
471
+
472
+ ## Support
473
+
474
+ If you find this project useful, please consider:
475
+ - ⭐ Starring the repository
476
+ - 🐛 Reporting bugs
477
+ - 💡 Suggesting new features
478
+ - 🤝 Contributing code or documentation
479
+ - 📢 Sharing with others
480
+
481
+ ---
482
+
483
+ **Made with ❤️ by the Video-React-New community**