Merge pull request #597 from psy/feature_streams

add remote files and streams to playAudio
This commit is contained in:
Kharhamel 2021-01-25 10:33:43 +01:00 committed by GitHub
commit d32fca9777
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -600,8 +600,18 @@ export class GameScene extends ResizableScene implements CenterListener {
if (url === undefined) {
audioManager.unloadAudio();
} else {
const mapDirUrl = this.MapUrlFile.substr(0, this.MapUrlFile.lastIndexOf('/'));
const realAudioPath = mapDirUrl + '/' + url;
const audioPath = url as string;
let realAudioPath = '';
if (audioPath.indexOf('://') > 0) {
// remote file or stream
realAudioPath = audioPath;
} else {
// local file, include it relative to map directory
const mapDirUrl = this.MapUrlFile.substr(0, this.MapUrlFile.lastIndexOf('/'));
realAudioPath = mapDirUrl + '/' + url;
}
audioManager.loadAudio(realAudioPath);
if (loop) {