mixSetTrackPlaybackPosition function mixer

bool mixSetTrackPlaybackPosition(
  1. Pointer<MixTrack> track,
  2. int frames
)

Seek a playing track to a new position in its input.

(Not to be confused with MIX_SetTrack3DPosition(), which is positioning of the track in 3D space, not the playback position of its audio data.)

On a playing track, the next time the mixer runs, it will start mixing from the new position.

Position is defined in sample frames of decoded audio, not units of time, so that sample-perfect mixing can be achieved. To instead operate in units of time, use MIX_TrackMSToFrames() to get the approximate sample frames for a given tick.

This function requires an input that can seek (so it can not be used if the input was set with MIX_SetTrackAudioStream()), and a audio file format that allows seeking. SDL_mixer's decoders for some file formats do not offer seeking, or can only seek to times, not exact sample frames, in which case the final position may be off by some amount of sample frames. Please check your audio data and file bug reports if appropriate.

It's legal to call this function on a track that is stopped, but a future call to MIX_PlayTrack() will reset the start position anyhow. Paused tracks will resume at the new input position.

\param track the track to change. \param frames the sample frame position to seek to. \returns true on success, false on error; call SDL_GetError() for details.

\threadsafety It is safe to call this function from any thread.

\since This function is available since SDL_mixer 3.0.0.

\sa MIX_GetTrackPlaybackPosition

extern SDL_DECLSPEC bool SDLCALL MIX_SetTrackPlaybackPosition(MIX_Track *track, Sint64 frames)

Implementation

bool mixSetTrackPlaybackPosition(Pointer<MixTrack> track, int frames) {
  final mixSetTrackPlaybackPositionLookupFunction = _libMixer
      .lookupFunction<
        Uint8 Function(Pointer<MixTrack> track, Int64 frames),
        int Function(Pointer<MixTrack> track, int frames)
      >('MIX_SetTrackPlaybackPosition');
  return mixSetTrackPlaybackPositionLookupFunction(track, frames) == 1;
}