resolve loadAudioFile error when query string in URL (#718)

When the URL contains a query string (e.g., "?lang=zh_cn") or is accessed with index.html, loadAudioFile fails to load the audio files. The issue has been resolved by removing that from the URL before before concatenating "src" link.
This commit is contained in:
An!
2023-12-03 00:25:22 +08:00
committed by GitHub
parent fce8af38a8
commit 42dcfef723
+5 -1
View File
@@ -204,7 +204,11 @@ var AudioEngine = {
},
loadAudioFile: function (src) {
if (src.indexOf('http') === -1) {
src = window.location + src;
var path = window.location.protocol + '//' + window.location.hostname + (window.location.port ?(':' + window.location.port) : '') + window.location.pathname;
if(path.endsWith('index.html')){
path = path.slice(0, - 10);
}
src = path + src;
}
if (AudioEngine.AUDIO_BUFFER_CACHE[src]) {
return new Promise(function (resolve, reject) {