-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.js
36 lines (31 loc) · 1.05 KB
/
demo.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
var audio;
//could initialise with Jquery
audioAnalyzer("#audio1", {
count: 100,
spacing: 2,
color: ['#FF2F2F', '#FFEB3B'],
callback: callback
});
function callback(analyzer) {
console.log(analyzer);
var sourceInput = document.querySelector("#sourceControl"),
visualInput = document.querySelector("#visualControl"),
colorInput = document.querySelector("#colorControl");
sourceInput.addEventListener('change', function() {
analyzer.audio.pause();
analyzer.audio.src = this[this.selectedIndex].value;
analyzer.audio.addEventListener("loadedmetadata", function() {
analyzer.audio.play();
}, false);
});
visualInput.addEventListener('change', function() {
analyzer.visual(this[this.selectedIndex].value);
});
colorInput.addEventListener('change', function() {
if (this[this.selectedIndex].value == 'color') {
analyzer.color('#00adef');
} else {
analyzer.color(['#FF2F2F', '#FFEB3B']);
}
});
}