|
|
@@ -4,14 +4,12 @@ window.ontouchmove = function(evt) { |
|
|
|
|
|
|
|
var currentSoundtrack = -1; |
|
|
|
function playSoundtrack(tracks) { |
|
|
|
console.log("Playing track..."); |
|
|
|
var keys = Object.keys(tracks); |
|
|
|
if (currentSoundtrack === -1) |
|
|
|
currentSoundtrack = randInt(0, keys.length); |
|
|
|
|
|
|
|
var key = keys[currentSoundtrack]; |
|
|
|
var track = tracks[key]; |
|
|
|
console.log("Playing track", key); |
|
|
|
|
|
|
|
var trackId = currentSoundtrack; |
|
|
|
while (currentSoundtrack === trackId) |
|
|
@@ -20,11 +18,8 @@ function playSoundtrack(tracks) { |
|
|
|
if (track.ready) { |
|
|
|
track.play(); |
|
|
|
track.once("ended", function() { playSoundtrack(tracks) }); |
|
|
|
console.log("playing immediately, as it's loaded"); |
|
|
|
} else { |
|
|
|
console.log("loading it..."); |
|
|
|
track.once("load", function() { |
|
|
|
console.log("loaded."); |
|
|
|
track.play(); |
|
|
|
track.once("ended", function() { playSoundtrack(tracks) }); |
|
|
|
}); |