Forum Discussion
Background Music Demo
If you want to stop the song you can run this trigger at the end of the scene or beginning of the next scene.
var player = GetPlayer();
this.Location= player.GetVar("location");
var audio = document.getElementById('bgSong');
audio.src = " ";
audio.load();
audio.play();
This will set the song to nothing, so it wont play anything.
If you want to change the music use the same trigger and set audio.src to loctation + the name of your song. You can control when and what song is playing throughout the course.
I hope this helps! Let me know if you need any assistance getting it to work :)
Thanks so much. I used this code to have the audio run in the background and it worked great:
<audio src="jazzfrenchy.mp3" id="bgSong" preload="auto" autoplay loop></audio>
I then added this exact code as a trigger to be executed when the scene ends but it didnt work:
var player = GetPlayer();
this.Location= player.GetVar("location");
var audio = document.getElementById('bgSong');
audio.src = " ";
audio.load();
audio.play();
I am in no way a coding expert. Any idea what I am missing?