我正在使用javascript对Windows应用商店应用进行编程,并且在播放质量不佳的音频时遇到问题。通常当声音播放时,它听起来好像正在跳过声音的前几百毫秒(有时甚至更多),导致咔嗒声,有时几乎没有声音(因为声音文件很短)。我有8个短文件(27kb .mp3)。最奇怪的是,播放的音量似乎也在安静和响亮的水平之间随机变化。我使用的是配备1.6GHz处理器的Windows 8.1平板电脑。
//I declare like this:
var playList = new Array("chord1.mp3", "chord2.mp3", "chord3.mp3", "chord4.mp3", "chord5.mp3", "chord6.mp3", "chord7.mp3", "chord8.mp3" );
var playListIndex = 0;
var players = new Array();
//I initialise like this:
for (var i = 0; i < playList.length; i++) {
players[i] = new Audio();
players[i].src = playList[i];
}
//When it's time to play (listening for pointerdown events) I do this:
players[playListIndex].play();
//I have tried this but it just introduces latency without solving the problem
//new Audio(playList[playListIndex]).play();
//This happens after playing to make the sounds play sequentially.
//The problems occur even when there is no overlap of playback
playListIndex++;
if (playListIndex >= playList.length) {
playListIndex = 0;
}
应用程序中几乎没有其他任何内容。建议非常感谢。