qt: Replace QSound with QSoundEffect

This commit is contained in:
Calcitem 2021-10-24 18:31:52 +08:00
parent 281f2b832b
commit 0f77c59319
No known key found for this signature in database
GPG Key ID: F67E4F8CB7B5EED2
1 changed files with 5 additions and 2 deletions

View File

@ -23,7 +23,7 @@
#include <QKeyEvent>
#include <QApplication>
#include <QTimer>
#include <QSound>
#include <QSoundEffect>
#include <QMessageBox>
#include <QAbstractButton>
#include <QPropertyAnimation>
@ -571,7 +571,10 @@ void Game::playSound(GameSound soundType, Color c)
}
if (hasSound) {
QSound::play(soundPath);
QSoundEffect *effect = new QSoundEffect;
effect->setSource(QUrl::fromLocalFile(soundPath));
effect->setLoopCount(1);
effect->play();
}
#endif /* ! DONOT_PLAY_SOUND */
}