forked from streamich/react-use
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuseVideo.story.tsx
33 lines (30 loc) · 1.15 KB
/
useVideo.story.tsx
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
import { storiesOf } from '@storybook/react';
import * as React from 'react';
import { useVideo } from '../src';
import ShowDocs from './util/ShowDocs';
const Demo = () => {
const [video, state, controls, ref] = useVideo(
<video src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" autoPlay={true} />
);
return (
<div>
{video}
<pre>{JSON.stringify(state, null, 2)}</pre>
<button onClick={controls.pause}>Pause</button>
<button onClick={controls.play}>Play</button>
<br />
<button onClick={controls.mute}>Mute</button>
<button onClick={controls.unmute}>Un-mute</button>
<br />
<button onClick={() => controls.volume(0.1)}>Volume: 10%</button>
<button onClick={() => controls.volume(0.5)}>Volume: 50%</button>
<button onClick={() => controls.volume(1)}>Volume: 100%</button>
<br />
<button onClick={() => controls.seek(state.time - 5)}>-5 sec</button>
<button onClick={() => controls.seek(state.time + 5)}>+5 sec</button>
</div>
);
};
storiesOf('UI|useVideo', module)
.add('Docs', () => <ShowDocs md={require('../docs/useVideo.md')} />)
.add('Demo', () => <Demo />);