aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/Sound.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/Sound.cpp')
-rw-r--r--src/crepe/Sound.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/crepe/Sound.cpp b/src/crepe/Sound.cpp
index f45a697..d48393c 100644
--- a/src/crepe/Sound.cpp
+++ b/src/crepe/Sound.cpp
@@ -1,9 +1,24 @@
#include "Sound.h"
+#include "SoundSystem.h"
using namespace crepe;
-Sound::Sound(std::unique_ptr<api::Resource> res) {
- _res = std::move(res);
+Sound::Sound(std::unique_ptr<api::Resource> res, SoundSystem & system) : system(system) {
+ this->res = std::move(res);
}
+void Sound::play() {
+ if (this->system.engine.getPause(this->handle)) {
+ // resume if paused
+ this->system.engine.setPause(this->handle, false);
+ } else {
+ // or start new sound
+ this->handle = this->system.engine.play(this->sample);
+ }
+}
+
+void Sound::pause() {
+ if (this->system.engine.getPause(this->handle)) return;
+ this->system.engine.setPause(this->handle, true);
+}