mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-17 17:43:52 +00:00
Retry login music playback when not playing
This commit is contained in:
parent
b05089aa3f
commit
a0d2461a6e
2 changed files with 21 additions and 5 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
#include "core/logger.hpp"
|
#include "core/logger.hpp"
|
||||||
#include "platform/process.hpp"
|
#include "platform/process.hpp"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
namespace wowee {
|
namespace wowee {
|
||||||
namespace audio {
|
namespace audio {
|
||||||
|
|
@ -75,6 +76,10 @@ void MusicManager::playMusic(const std::string& mpqPath, bool loop) {
|
||||||
void MusicManager::playFilePath(const std::string& filePath, bool loop) {
|
void MusicManager::playFilePath(const std::string& filePath, bool loop) {
|
||||||
if (filePath.empty()) return;
|
if (filePath.empty()) return;
|
||||||
if (filePath == currentTrack && playing) return;
|
if (filePath == currentTrack && playing) return;
|
||||||
|
if (!std::filesystem::exists(filePath)) {
|
||||||
|
LOG_WARNING("Music: file not found: ", filePath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
stopCurrentProcess();
|
stopCurrentProcess();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include "pipeline/asset_manager.hpp"
|
#include "pipeline/asset_manager.hpp"
|
||||||
#include "audio/music_manager.hpp"
|
#include "audio/music_manager.hpp"
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
#include <filesystem>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
@ -75,19 +76,29 @@ void AuthScreen::render(auth::AuthHandler& authHandler) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto& app = core::Application::getInstance();
|
||||||
|
auto* renderer = app.getRenderer();
|
||||||
if (!musicInitAttempted) {
|
if (!musicInitAttempted) {
|
||||||
musicInitAttempted = true;
|
musicInitAttempted = true;
|
||||||
auto& app = core::Application::getInstance();
|
|
||||||
auto* renderer = app.getRenderer();
|
|
||||||
auto* assets = app.getAssetManager();
|
auto* assets = app.getAssetManager();
|
||||||
if (renderer) {
|
if (renderer) {
|
||||||
auto* music = renderer->getMusicManager();
|
auto* music = renderer->getMusicManager();
|
||||||
if (music && assets && assets->isInitialized() && !music->isInitialized()) {
|
if (music && assets && assets->isInitialized() && !music->isInitialized()) {
|
||||||
music->initialize(assets);
|
music->initialize(assets);
|
||||||
}
|
}
|
||||||
if (music && !musicPlaying) {
|
}
|
||||||
music->playFilePath("assets/20-taverns.mp3", true);
|
}
|
||||||
musicPlaying = true;
|
if (renderer) {
|
||||||
|
auto* music = renderer->getMusicManager();
|
||||||
|
if (music) {
|
||||||
|
music->update(ImGui::GetIO().DeltaTime);
|
||||||
|
if (!music->isPlaying()) {
|
||||||
|
std::string path = "assets/20-taverns.mp3";
|
||||||
|
if (!std::filesystem::exists(path)) {
|
||||||
|
path = (std::filesystem::current_path() / "assets/20-taverns.mp3").string();
|
||||||
|
}
|
||||||
|
music->playFilePath(path, true);
|
||||||
|
musicPlaying = music->isPlaying();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue