Looking the Audio Scriptiong project to see how sounds are played.
I want to play external sounds on runtime, and adding an URL it works.
But i can't control that sound in events for play, add, FX or whatever, due there is no tag.
How i add in the script a tag for an audio file to be referenced in events to manage like any other sound for play/stop/resume/fx/ or whatever by tag ?
// Audio manager class for handling audio playback.
let audioManager = null;
// References to loaded audio files as global variables
let audioSfx5 = null;
let audioSfx7 = null;
let audioEpicArpg = null;
runOnStartup(async runtime =>
{
// Initialise the audio manager. See AudioManager.js for details.
audioManager = new AudioManager(runtime);
// During the loading screen, load both sound files as
// AudioBuffers and the music track all in parallel, so
// they are ready for immediate playback on startup.
[audioSfx5, audioSfx7, audioEpicArpg] = await Promise.all([
audioManager.loadSound("Sfx5.webm"),
audioManager.loadSound("sfx7.webm"),
audioManager.loadMusic("epicArpg.webm")
]);
});
// These functions are called by the button click events.
function PlaySfx5()
{
audioManager.playSound(audioSfx5);
}
function PlaySfx7()
{
audioManager.playSound(audioSfx7);
}
function PlayMusic()
{
audioManager.playMusic(audioEpicArpg);
}