Skip to content

Commit e0ddd39

Browse files
committed
Initial DefaultPlayer and demo setup using HoC
Basic setup to be iterated upon
1 parent 92c50d0 commit e0ddd39

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+327
-1439
lines changed

demo/assets/sintel-en.vtt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
WEBVTT - Sintel Caption File
2+
3+
Sage
4+
00:00:12.000 --> 00:00:15.000
5+
What brings you to the land
6+
of the gatekeepers?
7+
8+
Searching
9+
00:00:18.500 --> 00:00:20.500
10+
I'm searching for someone.
11+
12+
Quest
13+
00:00:36.500 --> 00:00:39.000
14+
A dangerous quest for a lone hunter.
15+
16+
Alone
17+
00:00:41.500 --> 00:00:44.000
18+
I've been alone for as long
19+
as I can remember.

demo/assets/sintel-es.vtt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
WEBVTT - Spanish Sintel Caption File
2+
3+
Sage
4+
00:00:12.000 --> 00:00:15.000
5+
Que te trae a la tierra
6+
de los porteros?
7+
8+
Searching
9+
00:00:18.500 --> 00:00:20.500
10+
Estoy buscando a alguien.
11+
12+
Quest
13+
00:00:36.500 --> 00:00:39.000
14+
Una busqueda peligrosa para un cazador solitario.
15+
16+
Alone
17+
00:00:41.500 --> 00:00:44.000
18+
He estado sola desde que recuerdo.

demo/generateConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module.exports = ({ optimize, extractCss, hot, publicPath = '/' }) => {
4646
? ExtractTextPlugin.extract('style', 'css')
4747
: 'style!css'
4848
}, {
49-
test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|svg)(\?.*)?$/,
49+
test: /\.(ico|jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|svg|vtt)(\?.*)?$/,
5050
loader: 'file'
5151
}]
5252
},

demo/src/components/App.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
import React from 'react';
2-
import { default as Video, Overlay, Controls } from 'react-html5video';
2+
import { DefaultPlayer as Video } from 'react-html5video';
33
import 'react-html5video/dist/styles.css';
4-
5-
import pkg from './../../../package.json';
64
import styles from './App.css';
5+
import pkg from './../../../package.json';
6+
import vttEn from './../../assets/sintel-en.vtt';
7+
import vttEs from './../../assets/sintel-es.vtt';
78

8-
const videoUrl = 'http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_h264.mov';
9+
const sintelTrailer = 'http://media.w3.org/2010/05/sintel/trailer.mp4';
910

1011
const App = () => (
1112
<div className={styles.component}>
1213
<h1 className={styles.copy}>This is a demo for "{pkg.name}".</h1>
13-
<Video
14-
className={styles.video}
15-
controls
16-
autoPlay
17-
loop
18-
muted>
19-
<source src={videoUrl} type="video/mp4" />
20-
<Overlay />
21-
<Controls />
14+
<Video className={styles.video}>
15+
<source src={sintelTrailer} type="video/mp4" />
16+
<track
17+
label="English"
18+
kind="subtitles"
19+
srcLang="en"
20+
src={vttEn}
21+
default />
22+
<track
23+
label="Español"
24+
kind="subtitles"
25+
srcLang="es"
26+
src={vttEs} />
2227
</Video>
2328
</div>
2429
);

generateConfig.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const distPath = path.resolve(__dirname, 'dist');
99
module.exports = (options = {}) => {
1010
return {
1111
entry: [
12-
path.resolve(srcPath, 'Entry.js')
12+
path.resolve(srcPath, 'entry.js')
1313
],
1414
target: 'web',
1515
output: {
@@ -27,6 +27,12 @@ module.exports = (options = {}) => {
2727
commonjs2: 'react',
2828
commonjs: 'react',
2929
amd: 'react'
30+
},
31+
'react-dom': {
32+
root: 'ReactDOM',
33+
commonjs2: 'react-dom',
34+
commonjs: 'react-dom',
35+
amd: 'react-dom'
3036
}
3137
}],
3238
module: {
@@ -40,7 +46,7 @@ module.exports = (options = {}) => {
4046
}, {
4147
test: /\.css$/,
4248
include: srcPath,
43-
loader: ExtractTextPlugin.extract('style', 'css?importLoaders=1&localIdentName=[hash:base64:5]&hashPrefix=react-html5video&-autoprefixer!postcss')
49+
loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=1&localIdentName=[hash:base64:5]&hashPrefix=react-html5video&-autoprefixer!postcss')
4450
}, {
4551
test: /\.(eot|ttf|woff|woff2|svg)(\?.*)?$/,
4652
loader: 'url'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"json"
4444
],
4545
"moduleNameMapper": {
46-
"^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|ico)$": "<rootDir>/__mocks__/fileMock.js",
46+
"^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|ico|vtt)$": "<rootDir>/__mocks__/fileMock.js",
4747
"^.+\\.css$": "identity-obj-proxy"
4848
},
4949
"testPathIgnorePatterns": [
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.component {
2+
position: relative;
3+
color: #fff;
4+
}
5+
6+
.button {}
7+
8+
.trackList {
9+
position: absolute;
10+
left: 0;
11+
bottom: 100%;
12+
display: none;
13+
background: #000;
14+
list-style: none;
15+
padding: 0;
16+
margin: 0;
17+
}
18+
19+
.component:hover .trackList {
20+
display: block;
21+
}
22+
23+
.trackItem {
24+
padding: 5px;
25+
}
26+
27+
.activeTrack {
28+
composes: trackItem;
29+
text-decoration: underline;
30+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React from 'react';
2+
import styles from './Captions.css';
3+
4+
export default ({ textTracks, getVideoEl, forceUpdateState, className }) => {
5+
return (
6+
<div className={[
7+
styles.component,
8+
className
9+
].join(' ')}>
10+
<button className={styles.button}>
11+
CC
12+
</button>
13+
<ul className={styles.trackList}>
14+
{ textTracks && Array.prototype.slice.call(textTracks).map((track, i) => (
15+
<li
16+
className={track.mode === 'showing'
17+
? styles.activeTrack
18+
: styles.trackItem}
19+
onClick={() => {
20+
const videoEl = getVideoEl()
21+
if (track.mode !== 'showing') {
22+
videoEl.textTracks[i].mode = 'showing';
23+
} else {
24+
videoEl.textTracks[i].mode = 'disabled';
25+
}
26+
// There is no `onTrackChange` event so we
27+
// have to forcibly update the video state
28+
// in order for the UI to update.
29+
forceUpdateState();
30+
}}
31+
key={track.language}>
32+
{ track.label }
33+
</li>
34+
))}
35+
</ul>
36+
</div>
37+
);
38+
};

src/DefaultPlayer/DefaultPlayer.css

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.component {
2+
position: relative;
3+
font-family: Helvetica;
4+
font-size: 11px;
5+
}
6+
7+
.video {
8+
width: 100%;
9+
height: 100%;
10+
}
11+
12+
.controls {
13+
position: absolute;
14+
bottom: 0;
15+
right: 0;
16+
left: 0;
17+
height: 34px;
18+
display: flex;
19+
}

src/DefaultPlayer/DefaultPlayer.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React from 'react';
2+
import video from './../Video/Video';
3+
import styles from './DefaultPlayer.css';
4+
import PlayPause from './PlayPause/PlayPause';
5+
import Seek from './Seek/Seek';
6+
import Volume from './Volume/Volume';
7+
8+
const DefaultPlayer = (props) => {
9+
const {
10+
video,
11+
children,
12+
className,
13+
...restProps
14+
} = props;
15+
return (
16+
<div className={[
17+
styles.component,
18+
className
19+
].join(' ')}>
20+
<video
21+
className={styles.video}
22+
{...restProps}>
23+
{ children }
24+
</video>
25+
<div className={styles.controls}>
26+
<PlayPause {...video} />
27+
<Seek {...video} />
28+
<Volume {...video} />
29+
</div>
30+
</div>
31+
);
32+
};
33+
34+
export default video(DefaultPlayer);

0 commit comments

Comments
 (0)