Skip to content

Commit

Permalink
resolve loadAudioFile error when query string in URL (#718)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
IceeAn authored Dec 2, 2023
1 parent fce8af3 commit 42dcfef
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion script/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 42dcfef

Please sign in to comment.