aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/AudioSource.cpp
diff options
context:
space:
mode:
authormax-001 <maxsmits21@knpmail.nl>2024-10-09 10:54:50 +0200
committermax-001 <maxsmits21@knpmail.nl>2024-10-09 10:54:50 +0200
commitf5b4e2c84326bd96c78ad1f6e4481c1970e54444 (patch)
treeaa75ef01ace01d86ffda93632e0b40dc11e0dcbc /src/crepe/api/AudioSource.cpp
parent765550bce8a81c6f0c79c0083b14ef68e0c900b2 (diff)
parent6b7a670d60fec808e4fd1fcf3a8df2c503dcbdf4 (diff)
Merge remote-tracking branch 'origin/master' into max/POC-ECS-homemade
Diffstat (limited to 'src/crepe/api/AudioSource.cpp')
-rw-r--r--src/crepe/api/AudioSource.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/crepe/api/AudioSource.cpp b/src/crepe/api/AudioSource.cpp
new file mode 100644
index 0000000..b512d27
--- /dev/null
+++ b/src/crepe/api/AudioSource.cpp
@@ -0,0 +1,22 @@
+#include "AudioSource.h"
+
+#include "../Sound.h"
+#include <memory>
+
+using namespace crepe::api;
+
+AudioSource::AudioSource(std::unique_ptr<Asset> audio_clip) {
+ this->sound = std::make_unique<crepe::Sound>(std::move(audio_clip));
+}
+
+void AudioSource::play() { return this->play(false); }
+
+void AudioSource::play(bool looping) {
+ this->sound->set_looping(looping);
+ this->sound->play();
+}
+
+void AudioSource::stop() {
+ this->sound->pause();
+ this->sound->rewind();
+}