This function will set the position (in seconds) for the given sound ID or asset.
The supplied "index" can either be a single instance of a sound (as returned from audio_play_sound()) or a sound asset (e.g. one added via The Asset Browser). The behaviour of this function will differ depending on the kind of index you have specified:
This function will only change the track position for the currently playing sound, or its next play (in case of a sound asset being supplied). If the sound is played with looping enabled, subsequent plays will always start from the beginning (0.0 seconds), not from the track position defined using this function. For example, starting a sound loop at 5.7 seconds will play the first sound from that point, however after that it will continue to repeat the whole track, from the beginning to the end.
audio_sound_set_track_position(index, time);
Argument | Type | Description |
---|---|---|
index | Sound Asset or Sound Instance ID | The index of the sound to change. |
time | Real | The time (in seconds) to set the start point to. Values beyond the end of the sound are clamped to its length. |
N/A
var snd = audio_play_sound(snd_MainTrack, 0, false);
audio_sound_set_track_position(snd, 32);
The above code plays a sound and then uses the returned ID value to set the start position for the sound to 32 seconds.