Can play Sound from a map script

add sound in the TutoMap
This commit is contained in:
DESKTOP-FMM8UI0\CLV 2021-04-21 16:47:19 +02:00
parent 676dbcc9d0
commit 517c0e86cb
6 changed files with 92 additions and 0 deletions

View file

@ -9,6 +9,8 @@ import {ClosePopupEvent} from "./Api/Events/ClosePopupEvent";
import {OpenTabEvent} from "./Api/Events/OpenTabEvent";
import {GoToPageEvent} from "./Api/Events/GoToPageEvent";
import {OpenCoWebSiteEvent} from "./Api/Events/OpenCoWebSiteEvent";
import {PlaySoundEvent} from "./Api/Events/PlaySoundEvent";
import SoundConfig = Phaser.Types.Sound.SoundConfig;
interface WorkAdventureApi {
sendChatMessage(message: string, author: string): void;
@ -24,6 +26,7 @@ interface WorkAdventureApi {
restorePlayerControl() : void;
displayBubble() : void;
removeBubble() : void;
playSound(url : string, config : SoundConfig): void;
}
declare global {
@ -113,6 +116,18 @@ window.WA = {
},'*');
},
playSound(url: string, config : SoundConfig) : string{
window.parent.postMessage({
"type" : 'playSound',
"data": {
url,
config
} as PlaySoundEvent
},'*');
return url;
},
goToPage(url : string) : void{
window.parent.postMessage({
"type" : 'goToPage',