Skip to content

Commit

Permalink
Add support for using OGG music instead of MP3 music.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lymia committed Jan 19, 2025
1 parent 9e46f03 commit b8780fa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
20 changes: 16 additions & 4 deletions coreengine/audiomanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ void AudioManager::loadMediaForFile(QString filePath, qint32 position)
file.open(QIODevice::ReadOnly);
m_player->m_content = file.readAll();
m_player->m_fileStream.open(QIODevice::ReadOnly);
m_player->m_player.setSourceDevice(&(m_player->m_fileStream));
m_player->m_player.setSourceDevice(&(m_player->m_fileStream), GlobalUtils::getUrlForFile(filePath));
m_player->m_player.setPosition(position);
}
#endif
Expand Down Expand Up @@ -554,7 +554,7 @@ void AudioManager::slotSetMuteInternal(bool value)
}
}

void AudioManager::SlotAddMusic(QString file, qint64 startPointMs, qint64 endPointMs)
bool AudioManager::tryAddMusic(QString file, qint64 startPointMs, qint64 endPointMs)
{
#ifdef AUDIOSUPPORT
if (!m_noAudio)
Expand All @@ -580,7 +580,18 @@ void AudioManager::SlotAddMusic(QString file, qint64 startPointMs, qint64 endPoi
CONSOLE_PRINT("Unable to locate music file: " + currentPath, GameConsole::eERROR);
}
}
#endif
#endif
}

void AudioManager::SlotAddMusic(QString file, qint64 startPointMs, qint64 endPointMs)
{
#ifdef AUDIOSUPPORT
bool success = tryAddMusic(file, startPointMs, endPointMs);
if (!success && file.endsWith(".wav") || file.endsWith(".mp3"))
{
tryAddMusic(file.first(file.length() - 4) + ".ogg", startPointMs, endPointMs);
}
#endif
}

#ifdef AUDIOSUPPORT
Expand Down Expand Up @@ -656,7 +667,8 @@ void AudioManager::loadMusicFolder(const QString & folder, QStringList& loadedSo
QDir directory(folder);
if (directory.exists())
{
QStringList filter("*.mp3");
QStringList filter;
filter << "*.mp3" << "*.wav" << "*.ogg";
QStringList files = directory.entryList(filter);
for (const auto& file : files)
{
Expand Down
1 change: 1 addition & 0 deletions coreengine/audiomanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ protected slots:
qint32 m_endpointMs{-1};
QString m_file;
};
bool tryAddMusic(QString file, qint64 startPointMs, qint64 endPointMs);
#ifdef AUDIOSUPPORT
spPlayer m_player;
QVector<PlaylistData> m_PlayListdata;
Expand Down
1 change: 1 addition & 0 deletions distribution/build_linux_appimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ EXCLUDES_LIST="
--exclude-library *libqtiff*
--exclude-library *libqwbmp*
--exclude-library *libqwebp*
--exclude-library *libgstreamermediaplugin*
"
$LINUXDEPLOY --appdir=distribution/AppDir \
-i distribution/res/icons/ico${SIDE}_linux_16.png --icon-filename=commander_wars_ico${SIDE} \
Expand Down

0 comments on commit b8780fa

Please sign in to comment.