2017-06-03 24 views
3

所以我試圖測試出使用Howler.js播放音頻文件。當我運行這個html文件並按下按鈕時,在控制檯中出現錯誤,提示「源文件數組必須通過任何新的哈爾傳遞。」Howler.js錯誤:'一個源文件數組必須通過任何新的哈爾'

HTML:

<!DOCTYPE html> 
<html> 
<head> 
<title>Play Sound</title> 
<script src='./howler.js/dist/howler.js'></script> 
</head> 
<body> 
<button id="btn">Play</button> 

<script> 
    var pong = new Howl({urls: ['sound.mp3', 'sound.ogg']}); 
    document.getElementById('btn').onclick=function(){pong.play();} 
</script> 
</body> 
</html> 

回答

3

應該

var pong = new Howl({ 
    src: ['sound.mp3', 'sound.ogg'] 
}); 
0

只是爲了未來的解決方案獵人,SRC屬性不是所有瀏覽器中工作。我用鉻金絲雀,它的工作。

相關問題