Skip to content

Commit

Permalink
improved loading code for audio
Browse files Browse the repository at this point in the history
  • Loading branch information
Robosturm committed Jan 19, 2025
1 parent c51775b commit e75a783
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions coreengine/audiomanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,14 +585,16 @@ bool AudioManager::tryAddMusic(QString file, qint64 startPointMs, qint64 endPoin
void AudioManager::SlotAddMusic(QString file, qint64 startPointMs, qint64 endPointMs)
{
#ifdef AUDIOSUPPORT
const QStringList supportedFormats = {".mp3", ".wav", ".ogg"};
bool success = tryAddMusic(file, startPointMs, endPointMs);
if (!success && file.endsWith(".wav") || file.endsWith(".mp3"))
for (qint32 i = 0; i < supportedFormats.length() && !success; ++i)
{
success = tryAddMusic(file.first(file.length() - 4) + ".ogg", startPointMs, endPointMs);
if (!success)
{
CONSOLE_PRINT("Unable to locate music file: " + file, GameConsole::eERROR);
}
QString filePath = file.first(file.lastIndexOf('.')) + supportedFormats[i];
success = tryAddMusic(filePath, startPointMs, endPointMs);
}
if (!success)
{
CONSOLE_PRINT("Unable to locate music file: " + file, GameConsole::eERROR);
}
#endif
}
Expand Down

0 comments on commit e75a783

Please sign in to comment.