-
Notifications
You must be signed in to change notification settings - Fork 0
/
audio.js
59 lines (47 loc) · 1.53 KB
/
audio.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
47
48
49
50
51
52
53
54
55
56
57
58
59
// var myContext = new (window.AudioContext || window.webkitAudioContext)();
var music;
var finishedLoadingAudio = false;
// function loadAudio(){
//Load the sounds
sounds.load([
"sounds/often.mp3"
]);
//Assign the callback function that should run
//when the sounds have loaded
sounds.whenLoaded = setup;
// }
function setup() {
music = sounds["sounds/often.mp3"];
music.loop = true;
finishedLoadingAudio = true;
var VARONE = { myvalue: true };
// if(VAR.myvalue){
// document.getElementById('overlay-main').style.display = 'none';
// }
setTimeout(hideLoadingScreen, 100);
}
function hideLoadingScreen(){
// music.play();
$("#overlay-main").fadeOut(700);
// document.getElementById('overlay-main').style.display = 'none';
}
function mute() {
document.getElementById('sound-on').style.display = 'none';
document.getElementById('sound-off').style.display = 'block';
music.pause();
}
function unmute() {
document.getElementById('sound-off').style.display = 'none';
document.getElementById('sound-on').style.display = 'block';
}
window.addEventListener('touchstart', function() {
// create empty buffer
// var buffer = myContext.createBuffer(1, 1, 22050);
// var source = myContext.createBufferSource();
// source.buffer = buffer;
// // connect to output (your speakers)
// source.connect(myContext.destination);
// play the file
// source.start(0);
music.play();
}, false);