From b868c2598ca5b1e1930daf990ee6947addf51c98 Mon Sep 17 00:00:00 2001 From: Clement Gournay Date: Sat, 18 Jul 2015 13:25:38 +0900 Subject: [PATCH] Sound gestion improved --- src/js/controller.js | 2 +- src/js/loader.js | 4 +++- src/js/loadsong.js | 2 +- src/js/soundsystem.js | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/js/controller.js b/src/js/controller.js index 0b6c6a8..86516ce 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -40,7 +40,7 @@ function Controller(selectedSong, songData){ _view.refresh(); } else if(ms>=0 && !started){ //when music starts - _game.playSound("main-music"); + assets.sounds["main-music"].play(); started=true; } diff --git a/src/js/loader.js b/src/js/loader.js index 82c6f87..3dc7da8 100644 --- a/src/js/loader.js +++ b/src/js/loader.js @@ -28,7 +28,9 @@ function Loader(){ audio.src = '/assets/audio/'+name; audio.load(); audio.onloadeddata = function(){ - assets.sounds[id] = audio; + assets.sounds[id] = new Audio(); + assets.sounds[id].src = audio.src; + assets.sounds[id].load(); _this.assetLoaded(); }; }); diff --git a/src/js/loadsong.js b/src/js/loadsong.js index 782660d..a18f24c 100644 --- a/src/js/loadsong.js +++ b/src/js/loadsong.js @@ -10,7 +10,7 @@ function loadSong(selectedSong){ this.run = function(){ - //assets.sounds["start"]["audio"][0].play(); + assets.sounds["start"].play(); $("#assets").append(""); var audio = new Audio(); diff --git a/src/js/soundsystem.js b/src/js/soundsystem.js index 7b7e35d..03e2a39 100644 --- a/src/js/soundsystem.js +++ b/src/js/soundsystem.js @@ -14,7 +14,7 @@ function soundSystem(controller){ _channels[i]["end"] = -1; _channels[i]["audio"] = new Audio(); } - + this.playSound = function(soundID){ for(var i=0;i<_channelMAX;i++){ //play in different sounds in different channels @@ -27,7 +27,7 @@ function soundSystem(controller){ break; } } - + } this.pauseSound = function(soundID, stop){