Added set playback time
This commit is contained in:
@@ -22,9 +22,9 @@ public:
|
|||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
SoundState GetState();
|
SoundState GetState();
|
||||||
float GetDuration();
|
|
||||||
float GetPlaybackTime();
|
float GetPlaybackTime();
|
||||||
bool SetRuntime();
|
bool SetPlaybackTime(float time);
|
||||||
|
float GetDuration();
|
||||||
void SetPosition(Magnum::Vector3 position);
|
void SetPosition(Magnum::Vector3 position);
|
||||||
Magnum::Vector3 GetPosition();
|
Magnum::Vector3 GetPosition();
|
||||||
void SetVolume(float value);
|
void SetVolume(float value);
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
#include "ChargeAudio.hpp"
|
#include "ChargeAudio.hpp"
|
||||||
|
#include <Corrade/Utility/Debug.h>
|
||||||
#include <Magnum/Magnum.h>
|
#include <Magnum/Magnum.h>
|
||||||
#include <Magnum/Math/Vector3.h>
|
#include <Magnum/Math/Vector3.h>
|
||||||
|
|
||||||
@@ -38,6 +39,22 @@ float Sound::GetPlaybackTime() {
|
|||||||
ma_sound_get_cursor_in_seconds(&this->maSound, &time);
|
ma_sound_get_cursor_in_seconds(&this->maSound, &time);
|
||||||
return 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
|
// Controls
|
||||||
void Sound::Play() {
|
void Sound::Play() {
|
||||||
ma_sound_start(&maSound);
|
ma_sound_start(&maSound);
|
||||||
|
Reference in New Issue
Block a user