forked from u-wave/react-vimeo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
98 lines (90 loc) · 2.3 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/* global document */
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import Vimeo from '../';
const videos = [
{ id: 115783408, name: 'Jambinai - Connection' },
{ id: 162959050, name: 'Jambinai - They Keep Silence' },
{ id: 169408731, name: 'Hoody - Like You' },
];
class App extends React.Component {
state = {
video: 0,
volume: 1,
paused: false,
};
selectVideo(index) {
this.setState({ video: index });
}
handlePause = (event) => {
this.setState({
paused: event.target.checked,
});
};
handlePlayerPause = () => {
this.setState({ paused: true });
};
handlePlayerPlay = () => {
this.setState({ paused: false });
};
handleVolume = (event) => {
this.setState({
volume: parseFloat(event.target.value),
});
};
render() {
const video = videos[this.state.video];
return (
<div className="row">
<div className="col s3">
<h3>Video</h3>
<div className="collection">
{videos.map((choice, index) => (
<a
href={`#!/video/${index}`}
className={`collection-item ${video === choice ? 'active' : ''}`}
onClick={() => this.selectVideo(index)}
>
{choice.name}
</a>
))}
</div>
<h3>Paused</h3>
<p>
<label htmlFor="paused">
<input
type="checkbox"
id="paused"
checked={this.state.paused}
onChange={this.handlePause}
/>
Paused
</label>
</p>
<h3>Volume</h3>
<input
type="range"
value={this.state.volume}
min={0}
max={1}
step={0.01}
onChange={this.handleVolume}
/>
</div>
<div className="col s9 center-align">
<Vimeo
video={video.id}
width={640}
height={480}
autoplay
volume={this.state.volume}
paused={this.state.paused}
onPause={this.handlePlayerPause}
onPlay={this.handlePlayerPlay}
/>
</div>
</div>
);
}
}
ReactDOM.render(<App />, document.getElementById('example'));