mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-04-05 04:33:51 +00:00
Play tavern music file on login screen
This commit is contained in:
parent
02f8328747
commit
b05089aa3f
7 changed files with 71 additions and 0 deletions
|
|
@ -72,6 +72,33 @@ void MusicManager::playMusic(const std::string& mpqPath, bool loop) {
|
|||
}
|
||||
}
|
||||
|
||||
void MusicManager::playFilePath(const std::string& filePath, bool loop) {
|
||||
if (filePath.empty()) return;
|
||||
if (filePath == currentTrack && playing) return;
|
||||
|
||||
stopCurrentProcess();
|
||||
|
||||
std::vector<std::string> args;
|
||||
args.push_back("-nodisp");
|
||||
args.push_back("-autoexit");
|
||||
if (loop) {
|
||||
args.push_back("-loop");
|
||||
args.push_back("0");
|
||||
}
|
||||
args.push_back("-volume");
|
||||
args.push_back("30");
|
||||
args.push_back(filePath);
|
||||
|
||||
playerPid = platform::spawnProcess(args);
|
||||
if (playerPid != INVALID_PROCESS) {
|
||||
playing = true;
|
||||
currentTrack = filePath;
|
||||
LOG_INFO("Music: Playing file ", filePath);
|
||||
} else {
|
||||
LOG_ERROR("Music: Failed to spawn ffplay process");
|
||||
}
|
||||
}
|
||||
|
||||
void MusicManager::stopMusic(float fadeMs) {
|
||||
(void)fadeMs; // ffplay doesn't support fade easily
|
||||
stopCurrentProcess();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue