From f431e769cc65f484241c036012939c1b7c8bd4a7 Mon Sep 17 00:00:00 2001 From: psy Date: Thu, 14 Jan 2021 11:45:14 +0100 Subject: [PATCH 1/2] add remote files and streams to playAudio --- front/src/Phaser/Game/GameScene.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index d25c2893..a6ec1662 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -599,7 +599,17 @@ export class GameScene extends ResizableScene implements CenterListener { 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 + realAudioPath = mapDirUrl + '/' + url; + } + audioManager.loadAudio(realAudioPath); if (loop) { From 8d67947bc19db6a34a8552093e612b490bdcc6d9 Mon Sep 17 00:00:00 2001 From: psy Date: Thu, 14 Jan 2021 11:48:06 +0100 Subject: [PATCH 2/2] move map url to else case --- front/src/Phaser/Game/GameScene.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index a6ec1662..021a7c8b 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -598,7 +598,6 @@ export class GameScene extends ResizableScene implements CenterListener { if (url === undefined) { audioManager.unloadAudio(); } else { - const mapDirUrl = this.MapUrlFile.substr(0, this.MapUrlFile.lastIndexOf('/')); const audioPath = url as string; let realAudioPath = ''; @@ -607,9 +606,10 @@ export class GameScene extends ResizableScene implements CenterListener { 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) {