Looping an audio in a specific place after starting it

I am trying to loop an audio in a specific time after the “intro” played (aka, the song starts, and when you enter the section of the main track, it will start looping instead of straight up starting and looping in a specific place)…

Is there like… any way to do that without separating the song in 2 different files? I have tried with the .addMarker but it makes the track play at the start of the loop instead of the start of the full track

I would guess you can still play the whole track by omitting the marker name. But if not I think you can add a second marker for the whole track.

So, basically I play the song then I play it again with the marker?

OK so, I have found a solution for this, if you want to play the track first you can do this so it plays the intro then the loop without dividing the track

create (){    
        this.music = this.sound.add('musicTrackKey')

        this.music.addMarker({
            name: 'loopPointKey',
            start: #, // this is where you should place the loopstart time in secs.
            config: {
                loop: true // Automatically loop
            }
        });

        this.music.play()
        
        this.music.on('complete', () => {
            this.music.play('loopPointKey'); // This should start playing the loop
        });
}

Might not be the best, but it works (too bad that there’s no “loopstart” so you can actually loop the music while starting it at the start instead of where the loop starts)

2 Likes