-
Notifications
You must be signed in to change notification settings - Fork 0
/
media-element.js
46 lines (43 loc) · 1.13 KB
/
media-element.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
import React from "react";
import { render } from "react-dom";
import {
RAudioContext,
RCycle,
RDelay,
RGain,
RMediaElementSource,
RPipeline,
} from "../index.js";
export default class MediaElementSourceExample extends React.Component {
constructor(props) {
super(props);
this.audio = new Audio("/assets/audio/clarinet.mp3");
this.audio.autoplay = true;
this.audio.loop = true;
}
render() {
return (
<RAudioContext debug={true}>
<article>
<h1>Media Element</h1>
<p>
This example demonstrates plugging a HTML5 Audio element to the{" "}
<em>r-audio</em> graph using <code>RMediaElementSource</code>. A
reference to the audio element could also be obtained via React
refs.
</p>
</article>
<RPipeline>
<RMediaElementSource element={this.audio} />
<RCycle>
<RPipeline>
<RDelay delayTime={0.3} />
<RGain gain={0.8} />
</RPipeline>
</RCycle>
<RGain gain={2} />
</RPipeline>
</RAudioContext>
);
}
}