-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
62 lines (58 loc) · 2.02 KB
/
index.html
File metadata and controls
62 lines (58 loc) · 2.02 KB
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
<link rel="stylesheet" href="app.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,800">
<div id="container">
<div id="hook"></div>
<h1>Play Music</h1>
<input type="file" id="files" name="files[]" multiple/>
</div>
<script crossorigin src="https://unpkg.com/react@15/dist/react.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@15/dist/react-dom.js"></script>
<script src="https://npmcdn.com/babel-core@5.8.38/browser.min.js"></script>
<script src="https://soulwire.github.io/sketch.js/js/sketch.min.js"></script>
<script src="app.js"></script>
<script type="text/babel">
const PlayButton = (props) => {
const className = props.isMusicPlaying
? 'play active'
: 'play';
return (
<a
href="#" title="Play video"
className={className}
onClick={props.onClick}
/>
);
};
class Container extends React.Component {
constructor(props) {
super(props);
this.state = {
isMusicPlaying: false,
};
}
// Отреагировать на щелчок мышью.
handleClick() {
this.audio[this.state.isMusicPlaying ? 'pause' : 'play']();
this.setState(prevState => {
return {
isMusicPlaying: !prevState.isMusicPlaying,
};
});
};
render() {
return (
<div>
<PlayButton
onClick={this.handleClick.bind(this)}
isMusicPlaying={this.state.isMusicPlaying}
/>
<audio id="audio" ref={(audioTag) => {
this.audio = audioTag;
}}/>
</div>
);
}
}
const placeWeWantToPutComponent = document.getElementById('hook');
ReactDOM.render(<Container />, placeWeWantToPutComponent);
</script>