Browse Source

`SeekMusicStream` initial implementation (#2006)

pull/2007/head
Uneven Prankster 3 years ago
committed by GitHub
parent
commit
19ef765382
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 0 deletions
  1. +22
    -0
      src/raudio.c
  2. +1
    -0
      src/raudio.h
  3. +1
    -0
      src/raylib.h

+ 22
- 0
src/raudio.c View File

@ -1656,6 +1656,28 @@ void StopMusicStream(Music music)
}
}
// Seek music to a certain position (in seconds)
void SeekMusicStream(Music music, float position)
{
unsigned int positionInFrames = (unsigned int)(position * music.stream.sampleRate);
switch (music.ctxType)
{
#if defined(SUPPORT_FILEFORMAT_WAV)
case MUSIC_AUDIO_WAV: drwav_seek_to_pcm_frame((drwav *)music.ctxData, positionInFrames); break;
#endif
#if defined(SUPPORT_FILEFORMAT_OGG)
case MUSIC_AUDIO_OGG: stb_vorbis_seek_frame((stb_vorbis *)music.ctxData, positionInFrames); break;
#endif
#if defined(SUPPORT_FILEFORMAT_FLAC)
case MUSIC_AUDIO_FLAC: drflac_seek_to_pcm_frame((drflac *)music.ctxData, positionInFrames); break;
#endif
#if defined(SUPPORT_FILEFORMAT_MP3)
case MUSIC_AUDIO_MP3: drmp3_seek_to_pcm_frame((drmp3 *)music.ctxData, positionInFrames); break;
#endif
default: break;
}
}
// Update (re-fill) music buffers if data already processed
void UpdateMusicStream(Music music)
{

+ 1
- 0
src/raudio.h View File

@ -171,6 +171,7 @@ void UpdateMusicStream(Music music); // Updates buffe
void StopMusicStream(Music music); // Stop music playing
void PauseMusicStream(Music music); // Pause music playing
void ResumeMusicStream(Music music); // Resume playing paused music
void SeekMusicStream(Music music, float position); // Seek music to a position (in seconds)
void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level)
void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level)
float GetMusicTimeLength(Music music); // Get music time length (in seconds)

+ 1
- 0
src/raylib.h View File

@ -1501,6 +1501,7 @@ RLAPI void UpdateMusicStream(Music music); // Updates
RLAPI void StopMusicStream(Music music); // Stop music playing
RLAPI void PauseMusicStream(Music music); // Pause music playing
RLAPI void ResumeMusicStream(Music music); // Resume playing paused music
RLAPI void SeekMusicStream(Music music, float position); // Seek music to a position (in seconds)
RLAPI void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level)
RLAPI void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level)
RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds)

Loading…
Cancel
Save