Javascript音频在chrome上开始非常低..它在边缘工作正常

时间:2017-02-27 18:48:02

标签: javascript html html5 google-chrome audio

我正在研究沙盒游戏,我开始添加一些音效......

问题是,音频在Edge上运行正常,但是当我在chrome或opera上尝试它时,(并且仅用于)污垢的音频开始非常低并且在几次重复播放这种声音效果之后它开始正常的音量(dirt0.volume总是显示1)..在边缘,它通常响亮。其他声音效果甚至在Chrome上工作正常,但我注意到重复的速度在Chrome上比在边缘上快得多..我不知道为什么但是我希望它们在每个浏览器上都相同..

我正常加载声音效果 像这样:

grass0 = new Audio('grass0.wav');

grass1 = new Audio('grass1.wav');

dirt0 = new Audio('dirt0.wav');

dirt1 = new Audio('dirt1.wav');

wood0 = new Audio('wood0.wav');

wood1 = new Audio('wood1.wav');

and then im just playing them by using .play() if none
of the other sound effects are playing.

if(grass0.paused & grass1.paused & dirt0.paused & dirt1.paused & wood0.paused & wood1.paused){

if(blocks[i].id == 1){ //Blok [1]

if(audio[0] == 0){

grass0.play();

audio[0] = 1;

}else{

grass1.play();

audio[0] = 0;

}

}else if(blocks[i].id == 2){ //Blok [2]

if(audio[1] == 0){

dirt0.play();

audio[1] = 1;

}else{

dirt1.play();

audio[1] = 0;

}

}else if(blocks[i].id == 7){ //Blok [7]

if(audio[2] == 0){

wood0.play();

audio[2] = 1;

}else{

wood1.play();

audio[2] = 0;

}

}

}

.. 

查看this视频,以便更好地理解。

0 个答案:

没有答案