-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathindex.js
More file actions
49 lines (42 loc) · 1.1 KB
/
index.js
File metadata and controls
49 lines (42 loc) · 1.1 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
import React from 'react';
import ReactDOM from 'react-dom';
import ShakaPlayer from 'shaka-player-react';
const STREAMS = [
{
name: 'Angel One MPEG-DASH',
src: 'https://storage.googleapis.com/shaka-demo-assets/angel-one/dash.mpd',
},
{
name: 'Big Buck Bunny HLS',
src:
'https://storage.googleapis.com/shaka-demo-assets/bbb-dark-truths-hls/hls.m3u8',
},
];
function App() {
const [show, setShow] = React.useState(false);
function onToggle() {
setShow(!show);
}
const [src, setSrc] = React.useState(STREAMS[0].src);
function onSelectSrc(event) {
setSrc(event.target.value);
}
return (
<div>
<div>
<button onClick={onToggle}>{show ? 'Hide' : 'Show'}</button>
</div>
<div>
<select value={src} onChange={onSelectSrc}>
{STREAMS.map(stream => (
<option key={stream.src} value={stream.src}>
{stream.name}
</option>
))}
</select>
</div>
{show && <ShakaPlayer autoPlay src={src} />}
</div>
);
}
ReactDOM.render(<App />, document.getElementById('app'));