Hey I just wanted to give a little heads up that if you play a sound at a position, it won’t loop until the full length of the track has elapsed, despite starting later.
That is to say, if you play a 2 minute sound at 30 seconds in, then there will be a 30 second silent gap before it loops.
Hey I managed to fix this myself by editing AudioSource.hx and editing private function timer_onRun () to reset offset = 0;
This means that when the sound is about to loop it won’t use the original offset put in.
This has removed the blank ‘gap’ during looping with an offset.
It’s strange, it appears to handle offset alright. It tells OpenAL to play, then sets currentTime to 0 (which should set the play position to 0 + offset). The timer should then run for length - currentTime, which should be the total length (minus the offset0 and the current play position (minus the offset).
What happens if you change line 198 from timer = new Timer (length - currentTime); to timer = new Timer (length - time);?
It looks like time is set to currentTime when it is created so that change didn’t make any difference.
So it might be that timer.run isn’t updated with the newer position? As if you change the position after playing a song, you still need to wait out the full original duration of the track?
That sounds like a great solution!
Yeah Timers aren’t the best, but the tracks have never felt out of sync and the tracks loop perfectly well.
Glad we were able to get to the bottom of it.