Added music

This commit is contained in:
Vladislav Khorev committed 2026-06-21 21:27:27 +03:00
1 parent 7db9ca8f70
commit 84f9fa37a8
13 files changed
+118 -8

No files matched your search

+14
View File
@@ -99,9 +99,20 @@ void AudioPlayerAsync::playSoundAsync(const std::string& filePath, int loops, in
}
void AudioPlayerAsync::playMusicAsync(const std::string& filePath, int loops) {
std::cout << "AudioPlayerAsync::playMusicAsync called step 1" << std::endl;
if (!initialized) return;
std::cout << "AudioPlayerAsync::playMusicAsync called step 1" << std::endl;
if (filePath == currentTrack)
{
return;
}
currentTrack = filePath;
auto task = [filePath, loops]() {
std::cout << "AudioPlayerAsync::playMusicAsync called step 3" << std::endl;
Mix_Music* music = Mix_LoadMUS(filePath.c_str());
if (!music) {
std::cerr << "Failed to load music " << filePath << ": " << Mix_GetError() << std::endl;
@@ -124,6 +135,9 @@ void AudioPlayerAsync::playMusicAsync(const std::string& filePath, int loops) {
void AudioPlayerAsync::stopMusicAsync() {
if (!initialized) return;
currentTrack = "";
#ifdef __EMSCRIPTEN__
Mix_HaltMusic();
#else