-
Notifications
You must be signed in to change notification settings - Fork 1
/
glue.js
36 lines (29 loc) · 904 Bytes
/
glue.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
/**
* Created by JetBrains WebStorm.
* User: kukulski
* Date: 12/10/11
* Time: 7:15 PM
* To change this template use File | Settings | File Templates.
*/
var playerElement;
function stop() {
if (playerElement) playerElement.pause();
}
function playDataURI(uri) {
stop();
playerElement = document.getElementById("player");
if(typeof(playerElement.play) == 'undefined')
alert("You don't seem to have a browser that supports audio. It's ok, you're not a bad person. But this app will now fail.");
playerElement.setAttribute("src", uri);
playerElement.play();
}
function play(bits) {
try {
var riffData = makeRiff(bits);
var url = makeDataUrl("audio/x-wav", riffData);
playDataURI(url);
document.getElementById('error').innerText = "";
} catch (err) {
document.getElementById('error').innerText = "" + err;
}
}