diff --git a/src/ChargeAudio.hpp b/src/ChargeAudio.hpp index ad783be..ff7337c 100644 --- a/src/ChargeAudio.hpp +++ b/src/ChargeAudio.hpp @@ -22,9 +22,9 @@ public: void Reset(); SoundState GetState(); - float GetDuration(); float GetPlaybackTime(); - bool SetRuntime(); + bool SetPlaybackTime(float time); + float GetDuration(); void SetPosition(Magnum::Vector3 position); Magnum::Vector3 GetPosition(); void SetVolume(float value); diff --git a/src/Sound.cpp b/src/Sound.cpp index 288b7ec..6bfc552 100644 --- a/src/Sound.cpp +++ b/src/Sound.cpp @@ -1,4 +1,5 @@ #include "ChargeAudio.hpp" +#include #include #include @@ -38,6 +39,22 @@ float Sound::GetPlaybackTime() { ma_sound_get_cursor_in_seconds(&this->maSound, &time); return time; } + +// true or false depending on if the playback was set +bool Sound::SetPlaybackTime(float time) { + // Better to just catch it from the start + if (time < 0) { + return false; + } + + bool result = ma_sound_seek_to_second(&maSound, time) != MA_SUCCESS; + if (result) { + Utility::Error{} << "Failed to set playback time to " << time + << " on a sound instance"; + } + return result; +} + // Controls void Sound::Play() { ma_sound_start(&maSound);