Here’s the updated version of @Stefan’s code:
//Replace the soundId with your own music!
let soundId = "gzGCdNYwaMpNMwPxOkVkHVTJ9lc0ExrEis89Eyazz9Q";
Sound.load(soundId, function (sound) {
playMusic(sound);
});
function playMusic(music : Sound) {
let currentPosition = Space.getProperty("trackPosition") || '0';
music.play(true);
music.currentPosition = parseFloat(currentPosition);
Application.onSceneExit(function() {
Space.setProperty("trackPosition", music.currentPosition.toString());
});
}