video-react-player 0.1.0
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 +27 -0
- package/LICENSE +23 -0
- package/README.md +584 -0
- package/dist/Manager.d.ts +36 -0
- package/dist/actions/player.d.ts +124 -0
- package/dist/actions/video.d.ts +161 -0
- package/dist/components/Bezel.d.ts +22 -0
- package/dist/components/BigPlayButton.d.ts +20 -0
- package/dist/components/ClickableComponent.d.ts +24 -0
- package/dist/components/LoadingSpinner.d.ts +11 -0
- package/dist/components/Player.d.ts +82 -0
- package/dist/components/PosterImage.d.ts +12 -0
- package/dist/components/Shortcut.d.ts +48 -0
- package/dist/components/Slider.d.ts +49 -0
- package/dist/components/Source.d.ts +25 -0
- package/dist/components/Video.d.ts +48 -0
- package/dist/components/control-bar/ClosedCaptionButton.d.ts +19 -0
- package/dist/components/control-bar/ControlBar.d.ts +17 -0
- package/dist/components/control-bar/DownloadButton.d.ts +17 -0
- package/dist/components/control-bar/ForwardControl.d.ts +13 -0
- package/dist/components/control-bar/ForwardReplayControl.d.ts +17 -0
- package/dist/components/control-bar/FullscreenToggle.d.ts +5 -0
- package/dist/components/control-bar/LoadProgressBar.d.ts +18 -0
- package/dist/components/control-bar/LoopToggle.d.ts +5 -0
- package/dist/components/control-bar/MouseTimeDisplay.d.ts +22 -0
- package/dist/components/control-bar/PictureInPictureToggle.d.ts +15 -0
- package/dist/components/control-bar/PlayProgressBar.d.ts +12 -0
- package/dist/components/control-bar/PlayToggle.d.ts +13 -0
- package/dist/components/control-bar/PlaybackRate.d.ts +14 -0
- package/dist/components/control-bar/PlaybackRateMenuButton.d.ts +17 -0
- package/dist/components/control-bar/ProgressControl.d.ts +16 -0
- package/dist/components/control-bar/QualityMenuButton.d.ts +17 -0
- package/dist/components/control-bar/ReplayControl.d.ts +13 -0
- package/dist/components/control-bar/ScreenshotButton.d.ts +14 -0
- package/dist/components/control-bar/SeekBar.d.ts +18 -0
- package/dist/components/control-bar/TheaterModeToggle.d.ts +14 -0
- package/dist/components/control-bar/VolumeMenuButton.d.ts +17 -0
- package/dist/components/menu/Menu.d.ts +15 -0
- package/dist/components/menu/MenuButton.d.ts +46 -0
- package/dist/components/menu/MenuItem.d.ts +22 -0
- package/dist/components/popup/Popup.d.ts +15 -0
- package/dist/components/popup/PopupButton.d.ts +19 -0
- package/dist/components/time-controls/CurrentTimeDisplay.d.ts +18 -0
- package/dist/components/time-controls/DurationDisplay.d.ts +12 -0
- package/dist/components/time-controls/RemainingTimeDisplay.d.ts +13 -0
- package/dist/components/time-controls/TimeDivider.d.ts +10 -0
- package/dist/components/volume-control/VolumeBar.d.ts +33 -0
- package/dist/components/volume-control/VolumeControl.d.ts +16 -0
- package/dist/components/volume-control/VolumeLevel.d.ts +9 -0
- package/dist/index.d.ts +46 -0
- package/dist/reducers/index.d.ts +11 -0
- package/dist/reducers/operation.d.ts +10 -0
- package/dist/reducers/player.d.ts +33 -0
- package/dist/types/component.d.ts +13 -0
- package/dist/types/player.d.ts +31 -0
- package/dist/utils/browser.d.ts +5 -0
- package/dist/utils/dom.d.ts +31 -0
- package/dist/utils/fullscreen.d.ts +16 -0
- package/dist/utils/index.d.ts +24 -0
- package/dist/video-react-new.cjs.js +3904 -0
- package/dist/video-react-new.css +1155 -0
- package/dist/video-react-new.d.ts +11 -0
- package/dist/video-react-new.es.js +3861 -0
- package/dist/video-react-new.full.js +4578 -0
- package/dist/video-react-new.full.min.js +2 -0
- package/dist/video-react-new.js +4283 -0
- package/dist/video-react-new.min.js +2 -0
- package/dist/video-react-player.cjs.js +3904 -0
- package/dist/video-react-player.css +1155 -0
- package/dist/video-react-player.d.ts +11 -0
- package/dist/video-react-player.es.js +3861 -0
- package/dist/video-react-player.full.js +4578 -0
- package/dist/video-react-player.full.min.js +2 -0
- package/dist/video-react-player.js +4283 -0
- package/dist/video-react-player.min.js +2 -0
- package/package.json +145 -0
- package/styles/fonts/video-react.eot +0 -0
- package/styles/fonts/video-react.svg +43 -0
- package/styles/fonts/video-react.ttf +0 -0
- package/styles/fonts/video-react.woff +0 -0
- package/styles/icons.json +584 -0
- package/styles/scss/components/bezel.scss +119 -0
- package/styles/scss/components/big-play-button.scss +45 -0
- package/styles/scss/components/button.scss +18 -0
- package/styles/scss/components/closed-caption.scss +13 -0
- package/styles/scss/components/control-bar.scss +51 -0
- package/styles/scss/components/control.scss +42 -0
- package/styles/scss/components/fullscreen.scss +13 -0
- package/styles/scss/components/loading-spinner.scss +105 -0
- package/styles/scss/components/menu/menu-inline.scss +67 -0
- package/styles/scss/components/menu/menu-popup.scss +27 -0
- package/styles/scss/components/menu/menu.scss +59 -0
- package/styles/scss/components/new-controls.scss +42 -0
- package/styles/scss/components/play-pause.scss +11 -0
- package/styles/scss/components/playback-rate.scss +13 -0
- package/styles/scss/components/poster.scss +27 -0
- package/styles/scss/components/progress.scss +157 -0
- package/styles/scss/components/slider.scss +13 -0
- package/styles/scss/components/time.scss +18 -0
- package/styles/scss/components/volume.scss +147 -0
- package/styles/scss/icons.scss +278 -0
- package/styles/scss/layout.scss +115 -0
- package/styles/scss/mixins.scss +117 -0
- package/styles/scss/variables.scss +16 -0
- package/styles/scss/video-react-player.scss +34 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<a name="0.21.4"></a>
|
|
2
|
+
## 0.21.4 (2025-12-26)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* rm docs pages ([4a7349d](https://github.com/thind9xdev/video-react-player/commit/4a7349d))
|
|
8
|
+
* rm docs pages [#2](https://github.com/thind9xdev/video-react-player/issues/2) ([38a455b](https://github.com/thind9xdev/video-react-player/commit/38a455b))
|
|
9
|
+
* update react 19 ([511554c](https://github.com/thind9xdev/video-react-player/commit/511554c))
|
|
10
|
+
* update readme ([0a4bcf4](https://github.com/thind9xdev/video-react-player/commit/0a4bcf4))
|
|
11
|
+
* update support react 19 ([a107d5a](https://github.com/thind9xdev/video-react-player/commit/a107d5a))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# Changelog
|
|
16
|
+
|
|
17
|
+
All notable changes to this project will be documented in this file.
|
|
18
|
+
|
|
19
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
20
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
21
|
+
|
|
22
|
+
## [Unreleased]
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
- **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/`).
|
|
26
|
+
- **TypeScript Support:** Resolved an issue where `npm` would fail to find type definitions (`@types/video-react-player`). The package now correctly bundles and declares its own TypeScript types.
|
|
27
|
+
- **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
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 video-react
|
|
4
|
+
Copyright (c) 2025 ZingMe.Vn
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
# video-react-player
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/video-react-player)
|
|
4
|
+
[](http://packagequality.com/#?package=video-react-player)
|
|
5
|
+
|
|
6
|
+
video-react-player is a web video player built from the ground up for an HTML5 world using React library on base Videojs.
|
|
7
|
+
|
|
8
|
+
### ✨ About video-react-player
|
|
9
|
+
|
|
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.
|
|
11
|
+
|
|
12
|
+
**Key Features:**
|
|
13
|
+
|
|
14
|
+
- 🎬 HTML5 video player built specifically for React
|
|
15
|
+
- ⚛️ Full support for React 15, 16, 17, 18, and 19
|
|
16
|
+
- 📱 Responsive design that works on mobile and desktop
|
|
17
|
+
- 🎨 Customizable UI with SCSS/CSS
|
|
18
|
+
- 🔌 Plugin support for HLS, DASH and other formats
|
|
19
|
+
- ♿ Accessibility features with keyboard controls
|
|
20
|
+
- 🌐 Multiple subtitle/caption track support
|
|
21
|
+
- 🎛️ Playback rate control
|
|
22
|
+
- 📺 Fullscreen support
|
|
23
|
+
- 🔊 Volume control with mute toggle
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
Install `video-react-player` and **peer dependencies** via NPM:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
npm install --save video-react-player react react-dom
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Or using Yarn:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
yarn add video-react-player react react-dom
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
### Import Styles
|
|
42
|
+
|
|
43
|
+
You need to import the CSS styles. Choose one of the following methods:
|
|
44
|
+
|
|
45
|
+
**Method 1: Import CSS directly in your JavaScript**
|
|
46
|
+
|
|
47
|
+
```jsx
|
|
48
|
+
import 'video-react-player/dist/video-react-player.css';
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Method 2: Import SCSS (for customization)**
|
|
52
|
+
|
|
53
|
+
```scss
|
|
54
|
+
@import '~video-react-player/styles/scss/video-react-player.scss';
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Method 3: Link in HTML**
|
|
58
|
+
|
|
59
|
+
```html
|
|
60
|
+
<link
|
|
61
|
+
rel="stylesheet"
|
|
62
|
+
href="https://unpkg.com/video-react-player/dist/video-react-player.css"
|
|
63
|
+
/>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Basic Example
|
|
67
|
+
|
|
68
|
+
Import the `Player` component and use it in your React application:
|
|
69
|
+
|
|
70
|
+
```jsx
|
|
71
|
+
import React from 'react';
|
|
72
|
+
import { Player } from 'video-react-player';
|
|
73
|
+
|
|
74
|
+
export default function VideoPlayer() {
|
|
75
|
+
return (
|
|
76
|
+
<Player>
|
|
77
|
+
<source src="https://media.w3.org/2010/05/sintel/trailer_hd.mp4" />
|
|
78
|
+
</Player>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Nextjs:
|
|
84
|
+
|
|
85
|
+
```jsx
|
|
86
|
+
import dynamic from 'next/dynamic';
|
|
87
|
+
import 'video-react-player/dist/video-react-player.css';
|
|
88
|
+
|
|
89
|
+
const Player = dynamic(() => import('video-react-player').then((m) => m.Player), {
|
|
90
|
+
ssr: false,
|
|
91
|
+
});
|
|
92
|
+
const ControlBar = dynamic(
|
|
93
|
+
() => import('video-react-player').then((m) => m.ControlBar),
|
|
94
|
+
{ ssr: false }
|
|
95
|
+
);
|
|
96
|
+
const BigPlayButton = dynamic(
|
|
97
|
+
() => import('video-react-player').then((m) => m.BigPlayButton),
|
|
98
|
+
{ ssr: false }
|
|
99
|
+
);
|
|
100
|
+
const PlayToggle = dynamic(
|
|
101
|
+
() => import('video-react-player').then((m) => m.PlayToggle),
|
|
102
|
+
{ ssr: false }
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
export default function Page() {
|
|
106
|
+
return (
|
|
107
|
+
<Player bigPlayButtonPosition="center" src="/video.mp4">
|
|
108
|
+
<ControlBar>
|
|
109
|
+
<PlayToggle />
|
|
110
|
+
</ControlBar>
|
|
111
|
+
</Player>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Advanced Example with Multiple Sources and Subtitles
|
|
117
|
+
|
|
118
|
+
```jsx
|
|
119
|
+
import React from 'react';
|
|
120
|
+
import { Player, BigPlayButton } from 'video-react-player';
|
|
121
|
+
|
|
122
|
+
export default function AdvancedPlayer() {
|
|
123
|
+
return (
|
|
124
|
+
<Player
|
|
125
|
+
playsInline
|
|
126
|
+
poster="/assets/poster.png"
|
|
127
|
+
src="https://media.w3.org/2010/05/sintel/trailer_hd.mp4"
|
|
128
|
+
>
|
|
129
|
+
<source src="https://media.w3.org/2010/05/sintel/trailer_hd.mp4" />
|
|
130
|
+
<track
|
|
131
|
+
kind="captions"
|
|
132
|
+
src="/assets/captions.en.vtt"
|
|
133
|
+
srclang="en"
|
|
134
|
+
label="English"
|
|
135
|
+
default
|
|
136
|
+
/>
|
|
137
|
+
<track
|
|
138
|
+
kind="captions"
|
|
139
|
+
src="/assets/captions.es.vtt"
|
|
140
|
+
srclang="es"
|
|
141
|
+
label="Spanish"
|
|
142
|
+
/>
|
|
143
|
+
<BigPlayButton position="center" />
|
|
144
|
+
</Player>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Controlling the Player
|
|
150
|
+
|
|
151
|
+
You can control the player programmatically using refs:
|
|
152
|
+
|
|
153
|
+
```jsx
|
|
154
|
+
import React, { useRef } from 'react';
|
|
155
|
+
import { Player } from 'video-react-player';
|
|
156
|
+
|
|
157
|
+
export default function ControlledPlayer() {
|
|
158
|
+
const playerRef = useRef(null);
|
|
159
|
+
|
|
160
|
+
const handlePlay = () => {
|
|
161
|
+
playerRef.current.play();
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const handlePause = () => {
|
|
165
|
+
playerRef.current.pause();
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const handleSeek = (seconds) => {
|
|
169
|
+
playerRef.current.seek(seconds);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<div>
|
|
174
|
+
<Player ref={playerRef}>
|
|
175
|
+
<source src="https://media.w3.org/2010/05/sintel/trailer_hd.mp4" />
|
|
176
|
+
</Player>
|
|
177
|
+
<button onClick={handlePlay}>Play</button>
|
|
178
|
+
<button onClick={handlePause}>Pause</button>
|
|
179
|
+
<button onClick={() => handleSeek(10)}>Skip to 10s</button>
|
|
180
|
+
</div>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Using Custom Controls
|
|
186
|
+
|
|
187
|
+
The new controls can be added to the player using the `ControlBar` component:
|
|
188
|
+
|
|
189
|
+
```jsx
|
|
190
|
+
import React from 'react';
|
|
191
|
+
import {
|
|
192
|
+
Player,
|
|
193
|
+
ControlBar,
|
|
194
|
+
PlayToggle,
|
|
195
|
+
VolumeMenuButton,
|
|
196
|
+
CurrentTimeDisplay,
|
|
197
|
+
TimeDivider,
|
|
198
|
+
DurationDisplay,
|
|
199
|
+
ProgressControl,
|
|
200
|
+
FullscreenToggle,
|
|
201
|
+
PictureInPictureToggle,
|
|
202
|
+
LoopToggle,
|
|
203
|
+
TheaterModeToggle,
|
|
204
|
+
DownloadButton,
|
|
205
|
+
ScreenshotButton,
|
|
206
|
+
QualityMenuButton,
|
|
207
|
+
PlaybackRateMenuButton,
|
|
208
|
+
} from 'video-react-player';
|
|
209
|
+
|
|
210
|
+
export default function CustomControlsPlayer() {
|
|
211
|
+
return (
|
|
212
|
+
<Player>
|
|
213
|
+
<source src="https://media.w3.org/2010/05/sintel/trailer_hd.mp4" />
|
|
214
|
+
<ControlBar>
|
|
215
|
+
<PlayToggle order={1} />
|
|
216
|
+
<VolumeMenuButton order={2} />
|
|
217
|
+
<CurrentTimeDisplay order={3} />
|
|
218
|
+
<TimeDivider order={4} />
|
|
219
|
+
<DurationDisplay order={5} />
|
|
220
|
+
<ProgressControl order={6} />
|
|
221
|
+
<LoopToggle order={7} />
|
|
222
|
+
<PlaybackRateMenuButton rates={[0.5, 1, 1.5, 2]} order={8} />
|
|
223
|
+
<QualityMenuButton
|
|
224
|
+
qualities={['auto', '1080p', '720p', '480p']}
|
|
225
|
+
order={9}
|
|
226
|
+
/>
|
|
227
|
+
<ScreenshotButton order={10} />
|
|
228
|
+
<DownloadButton order={11} />
|
|
229
|
+
<PictureInPictureToggle order={12} />
|
|
230
|
+
<TheaterModeToggle order={13} />
|
|
231
|
+
<FullscreenToggle order={14} />
|
|
232
|
+
</ControlBar>
|
|
233
|
+
</Player>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Using with State Management
|
|
239
|
+
|
|
240
|
+
```jsx
|
|
241
|
+
import React, { useRef, useEffect } from 'react';
|
|
242
|
+
import { Player } from 'video-react-player';
|
|
243
|
+
|
|
244
|
+
export default function StatePlayer() {
|
|
245
|
+
const playerRef = useRef(null);
|
|
246
|
+
|
|
247
|
+
useEffect(() => {
|
|
248
|
+
// Subscribe to player state changes
|
|
249
|
+
playerRef.current.subscribeToStateChange((state, prevState) => {
|
|
250
|
+
console.log('Current time:', state.currentTime);
|
|
251
|
+
console.log('Duration:', state.duration);
|
|
252
|
+
console.log('Playing:', !state.paused);
|
|
253
|
+
});
|
|
254
|
+
}, []);
|
|
255
|
+
|
|
256
|
+
return (
|
|
257
|
+
<Player ref={playerRef}>
|
|
258
|
+
<source src="https://media.w3.org/2010/05/sintel/trailer_hd.mp4" />
|
|
259
|
+
</Player>
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Available Components
|
|
265
|
+
|
|
266
|
+
- `Player` - Main video player component
|
|
267
|
+
- `BigPlayButton` - Large play button overlay
|
|
268
|
+
- `LoadingSpinner` - Loading indicator
|
|
269
|
+
- `PosterImage` - Poster image component
|
|
270
|
+
- `ControlBar` - Player control bar
|
|
271
|
+
- `PlayToggle` - Play/pause button
|
|
272
|
+
- `ForwardControl` - Forward skip button
|
|
273
|
+
- `ReplayControl` - Replay/rewind button
|
|
274
|
+
- `FullscreenToggle` - Fullscreen button
|
|
275
|
+
- `PictureInPictureToggle` - Picture-in-picture button
|
|
276
|
+
- `TheaterModeToggle` - Theater mode button
|
|
277
|
+
- `LoopToggle` - Loop playback button
|
|
278
|
+
- `ProgressControl` - Progress bar
|
|
279
|
+
- `SeekBar` - Seekable progress bar
|
|
280
|
+
- `PlaybackRateMenuButton` - Playback speed control
|
|
281
|
+
- `QualityMenuButton` - Quality selection menu
|
|
282
|
+
- `VolumeMenuButton` - Volume control
|
|
283
|
+
- `ClosedCaptionButton` - Closed captions toggle
|
|
284
|
+
- `DownloadButton` - Download video button
|
|
285
|
+
- `ScreenshotButton` - Take screenshot button
|
|
286
|
+
- `RemainingTimeDisplay` - Remaining time display
|
|
287
|
+
- `CurrentTimeDisplay` - Current time display
|
|
288
|
+
- `DurationDisplay` - Total duration display
|
|
289
|
+
- `TimeDivider` - Time divider
|
|
290
|
+
- `Bezel` - Animated bezel for actions
|
|
291
|
+
- `Shortcut` - Keyboard shortcuts
|
|
292
|
+
|
|
293
|
+
## API Documentation
|
|
294
|
+
|
|
295
|
+
### Player Props
|
|
296
|
+
|
|
297
|
+
| Prop | Type | Default | Description |
|
|
298
|
+
| ------------- | ------- | -------- | -------------------------------------------- |
|
|
299
|
+
| `fluid` | boolean | `true` | Player size follows container width |
|
|
300
|
+
| `width` | number | - | Player width in pixels |
|
|
301
|
+
| `height` | number | - | Player height in pixels |
|
|
302
|
+
| `src` | string | - | Video source URL |
|
|
303
|
+
| `poster` | string | - | Poster image URL |
|
|
304
|
+
| `preload` | string | `'auto'` | Preload strategy: 'auto', 'metadata', 'none' |
|
|
305
|
+
| `autoPlay` | boolean | `false` | Autoplay video on load |
|
|
306
|
+
| `loop` | boolean | `false` | Loop video playback |
|
|
307
|
+
| `muted` | boolean | `false` | Mute video by default |
|
|
308
|
+
| `playsInline` | boolean | `false` | Play inline on mobile devices |
|
|
309
|
+
| `aspectRatio` | string | `'auto'` | Aspect ratio (e.g., '16:9', '4:3') |
|
|
310
|
+
| `startTime` | number | - | Start playback at specific time (seconds) |
|
|
311
|
+
|
|
312
|
+
### Player Methods (via ref)
|
|
313
|
+
|
|
314
|
+
| Method | Description |
|
|
315
|
+
| ---------------------------------- | ------------------------------------------- |
|
|
316
|
+
| `play()` | Start playback |
|
|
317
|
+
| `pause()` | Pause playback |
|
|
318
|
+
| `load()` | Load video |
|
|
319
|
+
| `seek(time)` | Seek to specific time in seconds |
|
|
320
|
+
| `forward(seconds)` | Skip forward by seconds |
|
|
321
|
+
| `replay(seconds)` | Skip backward by seconds |
|
|
322
|
+
| `changeRate(rate)` | Change playback rate (0.5, 1, 1.5, 2, etc.) |
|
|
323
|
+
| `changeVolume(volume)` | Change volume (0 to 1) |
|
|
324
|
+
| `mute()` | Mute audio |
|
|
325
|
+
| `unmute()` | Unmute audio |
|
|
326
|
+
| `toggleFullscreen()` | Toggle fullscreen mode |
|
|
327
|
+
| `subscribeToStateChange(callback)` | Subscribe to state changes |
|
|
328
|
+
|
|
329
|
+
## Browser support
|
|
330
|
+
|
|
331
|
+
| Browser | Windows | Mac | Linux | Android | iOS |
|
|
332
|
+
| :-----: | :------: | :-----: | :-----: | :-----: | :--------: |
|
|
333
|
+
| Chrome | **Yes** | **Yes** | **Yes** | **Yes** | **Native** |
|
|
334
|
+
| Firefox | **Yes** | **Yes** | **Yes** | **Yes** | **Native** |
|
|
335
|
+
| Edge | **Yes** | **Yes** | - | - | - |
|
|
336
|
+
| IE 11 | Untested | - | - | - | - |
|
|
337
|
+
| Safari | - | **Yes** | - | - | **Yes** |
|
|
338
|
+
|
|
339
|
+
**Notes:**
|
|
340
|
+
|
|
341
|
+
- Only the latest stable version is actively tested and supported
|
|
342
|
+
- video-react-player may work in older browser releases, and we accept pull requests for them
|
|
343
|
+
- "Native" means the browser's native video player is used on mobile
|
|
344
|
+
- For "Untested" browsers, community testing is welcome
|
|
345
|
+
|
|
346
|
+
## HLS and DASH Support
|
|
347
|
+
|
|
348
|
+
For HLS (HTTP Live Streaming) playback, you can use [hls.js](https://github.com/video-dev/hls.js):
|
|
349
|
+
|
|
350
|
+
```jsx
|
|
351
|
+
import React, { useRef, useEffect } from 'react';
|
|
352
|
+
import { Player } from 'video-react-player';
|
|
353
|
+
import Hls from 'hls.js';
|
|
354
|
+
|
|
355
|
+
export default function HLSPlayer() {
|
|
356
|
+
const playerRef = useRef(null);
|
|
357
|
+
|
|
358
|
+
useEffect(() => {
|
|
359
|
+
const player = playerRef.current;
|
|
360
|
+
if (Hls.isSupported()) {
|
|
361
|
+
const hls = new Hls();
|
|
362
|
+
hls.loadSource('https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8');
|
|
363
|
+
hls.attachMedia(player.video.video);
|
|
364
|
+
} else if (
|
|
365
|
+
player.video.video.canPlayType('application/vnd.apple.mpegurl')
|
|
366
|
+
) {
|
|
367
|
+
player.video.video.src =
|
|
368
|
+
'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8';
|
|
369
|
+
}
|
|
370
|
+
}, []);
|
|
371
|
+
|
|
372
|
+
return (
|
|
373
|
+
<Player ref={playerRef}>
|
|
374
|
+
<source
|
|
375
|
+
src="https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"
|
|
376
|
+
type="application/x-mpegURL"
|
|
377
|
+
/>
|
|
378
|
+
</Player>
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
## Keyboard Shortcuts
|
|
384
|
+
|
|
385
|
+
When the player is focused, you can use these keyboard shortcuts:
|
|
386
|
+
|
|
387
|
+
| Key | Action |
|
|
388
|
+
| -------------- | ----------------------- |
|
|
389
|
+
| `Space` or `K` | Play/Pause |
|
|
390
|
+
| `←` | Rewind 5 seconds |
|
|
391
|
+
| `→` | Forward 5 seconds |
|
|
392
|
+
| `↑` | Increase volume |
|
|
393
|
+
| `↓` | Decrease volume |
|
|
394
|
+
| `F` | Toggle fullscreen |
|
|
395
|
+
| `M` | Toggle mute |
|
|
396
|
+
| `0-9` | Jump to 0%-90% of video |
|
|
397
|
+
| `Home` | Jump to beginning |
|
|
398
|
+
| `End` | Jump to end |
|
|
399
|
+
|
|
400
|
+
## Styling and Customization
|
|
401
|
+
|
|
402
|
+
The player can be styled using CSS or SCSS. All components have BEM-style class names:
|
|
403
|
+
|
|
404
|
+
```css
|
|
405
|
+
/* Custom player styles */
|
|
406
|
+
.video-react-player .video-react-player-big-play-button {
|
|
407
|
+
background-color: #ff0000;
|
|
408
|
+
border-color: #ff0000;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.video-react-player .video-react-player-control-bar {
|
|
412
|
+
background-color: rgba(0, 0, 0, 0.7);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
.video-react-player .video-react-player-play-progress {
|
|
416
|
+
background-color: #ff0000;
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
For SCSS customization, you can override variables before importing:
|
|
421
|
+
|
|
422
|
+
```scss
|
|
423
|
+
// Override default variables
|
|
424
|
+
$primary-background-color: #000;
|
|
425
|
+
$primary-foreground-color: #fff;
|
|
426
|
+
$primary-color: #ff0000;
|
|
427
|
+
|
|
428
|
+
// Import the styles
|
|
429
|
+
@import '~video-react-player/styles/scss/video-react-player.scss';
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
## Development
|
|
433
|
+
|
|
434
|
+
### Setup
|
|
435
|
+
|
|
436
|
+
Clone the repository and install dependencies:
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
git clone https://github.com/thind9xdev/video-react-player.git
|
|
440
|
+
cd video-react-player
|
|
441
|
+
npm install
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
### Run Development Server
|
|
445
|
+
|
|
446
|
+
Start the development server with hot reloading:
|
|
447
|
+
|
|
448
|
+
```bash
|
|
449
|
+
npm start
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
The documentation site will be available at `http://localhost:8000`.
|
|
453
|
+
|
|
454
|
+
### Run Tests
|
|
455
|
+
|
|
456
|
+
Run the test suite:
|
|
457
|
+
|
|
458
|
+
```bash
|
|
459
|
+
npm test
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
Run tests in watch mode:
|
|
463
|
+
|
|
464
|
+
```bash
|
|
465
|
+
npm run test:watch
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
Run tests with coverage:
|
|
469
|
+
|
|
470
|
+
```bash
|
|
471
|
+
npm run test:coverage
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
### Build
|
|
475
|
+
|
|
476
|
+
Build the library:
|
|
477
|
+
|
|
478
|
+
```bash
|
|
479
|
+
npm run build
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
Build the documentation:
|
|
483
|
+
|
|
484
|
+
```bash
|
|
485
|
+
npm run build-docs
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### Linting
|
|
489
|
+
|
|
490
|
+
Run ESLint:
|
|
491
|
+
|
|
492
|
+
```bash
|
|
493
|
+
npm run lint
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
Format code with Prettier:
|
|
497
|
+
|
|
498
|
+
```bash
|
|
499
|
+
npm run format-all
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
## Contribution
|
|
503
|
+
|
|
504
|
+
We welcome contributions! If you'd like to contribute to video-react-player:
|
|
505
|
+
|
|
506
|
+
1. **Fork the repository** on GitHub
|
|
507
|
+
2. **Clone your fork** locally
|
|
508
|
+
3. **Create a feature branch**: `git checkout -b my-new-feature`
|
|
509
|
+
4. **Make your changes** and add tests if applicable
|
|
510
|
+
5. **Run tests**: `npm test`
|
|
511
|
+
6. **Commit your changes**: `git commit -am 'Add some feature'`
|
|
512
|
+
7. **Push to the branch**: `git push origin my-new-feature`
|
|
513
|
+
8. **Submit a pull request**
|
|
514
|
+
|
|
515
|
+
For more detailed information, please read the [contribution guide](./CONTRIBUTION.md).
|
|
516
|
+
|
|
517
|
+
### Reporting Issues
|
|
518
|
+
|
|
519
|
+
If you encounter a bug or have a feature request:
|
|
520
|
+
|
|
521
|
+
1. Check the [issue list](https://github.com/thind9xdev/video-react-player-dart/issues) first
|
|
522
|
+
2. If not already reported, create a new issue
|
|
523
|
+
3. Provide as much detail as possible:
|
|
524
|
+
- Steps to reproduce the bug
|
|
525
|
+
- Expected vs actual behavior
|
|
526
|
+
- Browser and version
|
|
527
|
+
- React version
|
|
528
|
+
- Code examples or screenshots
|
|
529
|
+
|
|
530
|
+
## FAQ
|
|
531
|
+
|
|
532
|
+
### How do I customize the player appearance?
|
|
533
|
+
|
|
534
|
+
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.
|
|
535
|
+
|
|
536
|
+
### Does it support HLS/DASH streaming?
|
|
537
|
+
|
|
538
|
+
Yes! You can use libraries like hls.js or dash.js with video-react-player. See the [HLS and DASH Support](#hls-and-dash-support) section.
|
|
539
|
+
|
|
540
|
+
### Can I use this with TypeScript?
|
|
541
|
+
|
|
542
|
+
Yes, the package includes TypeScript type definitions.
|
|
543
|
+
|
|
544
|
+
### How do I access the native video element?
|
|
545
|
+
|
|
546
|
+
Use a ref to access the player, then use `playerRef.current.video.video` to access the native HTML5 video element.
|
|
547
|
+
|
|
548
|
+
### Does it work with Next.js?
|
|
549
|
+
|
|
550
|
+
Yes, video-react-player works with Next.js. Just make sure to import styles appropriately for your Next.js configuration.
|
|
551
|
+
|
|
552
|
+
## License
|
|
553
|
+
|
|
554
|
+
MIT © [video-react-player Contributors](https://github.com/thind9xdev/video-react-player/graphs/contributors)
|
|
555
|
+
|
|
556
|
+
## Inspiration & Credits
|
|
557
|
+
|
|
558
|
+
- This project is a maintained fork of [video-react](https://github.com/video-react/video-react)
|
|
559
|
+
- Heavily inspired by [video.js](http://www.videojs.com)
|
|
560
|
+
- CSS styles adapted from [video.js's styles](https://github.com/videojs/video.js/tree/master/src/css)
|
|
561
|
+
- Documentation site built with [reactstrap](https://github.com/reactstrap/reactstrap)
|
|
562
|
+
- Icons from [Google Material Icons](https://material.io/icons/)
|
|
563
|
+
- Fonts built with [IcoMoon](https://icomoon.io/)
|
|
564
|
+
|
|
565
|
+
## Links
|
|
566
|
+
|
|
567
|
+
- [GitHub Repository](https://github.com/thind9xdev/video-react-player)
|
|
568
|
+
- [NPM Package](https://www.npmjs.com/package/video-react-player)
|
|
569
|
+
- [Issue Tracker](https://github.com/thind9xdev/video-react-player/issues)
|
|
570
|
+
- [Changelog](./CHANGELOG.md)
|
|
571
|
+
|
|
572
|
+
## Support
|
|
573
|
+
|
|
574
|
+
If you find this project useful, please consider:
|
|
575
|
+
|
|
576
|
+
- ⭐ Starring the repository
|
|
577
|
+
- 🐛 Reporting bugs
|
|
578
|
+
- 💡 Suggesting new features
|
|
579
|
+
- 🤝 Contributing code or documentation
|
|
580
|
+
- 📢 Sharing with others
|
|
581
|
+
|
|
582
|
+
---
|
|
583
|
+
|
|
584
|
+
**Made with ❤️ by the video-react-player community**
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Store, Unsubscribe } from 'redux';
|
|
2
|
+
import { RootState } from './reducers';
|
|
3
|
+
type BindThis = (...args: any[]) => any;
|
|
4
|
+
export type ActionCreators = Record<string, BindThis>;
|
|
5
|
+
export interface VideoAPI {
|
|
6
|
+
play(): Promise<void> | void;
|
|
7
|
+
pause(): Promise<void> | void;
|
|
8
|
+
load(): void;
|
|
9
|
+
addTextTrack(kind: TextTrackKind, label?: string, language?: string): TextTrack;
|
|
10
|
+
canPlayType(...args: Parameters<HTMLVideoElement['canPlayType']>): CanPlayTypeResult;
|
|
11
|
+
togglePlay(): void;
|
|
12
|
+
seek(time: number): void;
|
|
13
|
+
forward(seconds: number): void;
|
|
14
|
+
replay(seconds: number): void;
|
|
15
|
+
toggleFullscreen(): void;
|
|
16
|
+
playbackRate: number;
|
|
17
|
+
muted: boolean;
|
|
18
|
+
volume: number;
|
|
19
|
+
videoWidth: number;
|
|
20
|
+
videoHeight: number;
|
|
21
|
+
video?: HTMLVideoElement | null;
|
|
22
|
+
}
|
|
23
|
+
export default class Manager {
|
|
24
|
+
store: Store<RootState>;
|
|
25
|
+
video: VideoAPI | null;
|
|
26
|
+
rootElement: HTMLElement | null;
|
|
27
|
+
boundActions: ActionCreators | undefined;
|
|
28
|
+
constructor(store?: Store<RootState>);
|
|
29
|
+
getActions(): ActionCreators;
|
|
30
|
+
getState(): RootState;
|
|
31
|
+
subscribeToStateChange(listener: (state: any, prevState: any) => void, getState?: () => any): Unsubscribe;
|
|
32
|
+
subscribeToOperationStateChange(listener: (state: RootState['operation'], prev: RootState['operation']) => void): Unsubscribe;
|
|
33
|
+
subscribeToPlayerStateChange(listener: (state: RootState['player'], prev: RootState['player']) => void): Unsubscribe;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=Manager.d.ts.map
|