diff --git a/aoblipplayer.cpp b/aoblipplayer.cpp index c58e2cc..5e3929e 100644 --- a/aoblipplayer.cpp +++ b/aoblipplayer.cpp @@ -2,9 +2,9 @@ AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app) { + m_sfxplayer = new QSoundEffect; m_parent = parent; ao_app = p_ao_app; - m_sfxplayer = new QMediaPlayer(m_parent, QMediaPlayer::Flag::LowLatency); } AOBlipPlayer::~AOBlipPlayer() @@ -17,18 +17,17 @@ void AOBlipPlayer::set_blips(QString p_sfx) { m_sfxplayer->stop(); QString f_path = ao_app->get_sounds_path() + p_sfx.toLower(); - m_sfxplayer->setMedia(QUrl::fromLocalFile(f_path)); + m_sfxplayer->setSource(QUrl::fromLocalFile(f_path)); set_volume(m_volume); } void AOBlipPlayer::blip_tick() { - //m_sfxplayer->stop(); m_sfxplayer->play(); } void AOBlipPlayer::set_volume(int p_value) { m_volume = p_value; - m_sfxplayer->setVolume(p_value); + m_sfxplayer->setVolume(p_value / 100.0); } diff --git a/aoblipplayer.h b/aoblipplayer.h index b460196..c8a8cb6 100644 --- a/aoblipplayer.h +++ b/aoblipplayer.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include class AOBlipPlayer { @@ -23,7 +23,7 @@ public: private: QWidget *m_parent; AOApplication *ao_app; - QMediaPlayer *m_sfxplayer; + QSoundEffect *m_sfxplayer; int m_volume; }; diff --git a/aosfxplayer.cpp b/aosfxplayer.cpp index c8e1593..69c1171 100644 --- a/aosfxplayer.cpp +++ b/aosfxplayer.cpp @@ -5,7 +5,7 @@ AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) { m_parent = parent; ao_app = p_ao_app; - m_sfxplayer = new QMediaPlayer(m_parent, QMediaPlayer::Flag::LowLatency); + m_sfxplayer = new QSoundEffect(); } AOSfxPlayer::~AOSfxPlayer() @@ -38,7 +38,7 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) else f_path = sound_path; - m_sfxplayer->setMedia(QUrl::fromLocalFile(f_path)); + m_sfxplayer->setSource(QUrl::fromLocalFile(f_path)); set_volume(m_volume); m_sfxplayer->play(); @@ -52,5 +52,5 @@ void AOSfxPlayer::stop() void AOSfxPlayer::set_volume(int p_value) { m_volume = p_value; - m_sfxplayer->setVolume(p_value); + m_sfxplayer->setVolume(p_value / 100.0); } diff --git a/aosfxplayer.h b/aosfxplayer.h index 4494b3e..ab398e0 100644 --- a/aosfxplayer.h +++ b/aosfxplayer.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include class AOSfxPlayer { @@ -21,7 +21,7 @@ public: private: QWidget *m_parent; AOApplication *ao_app; - QMediaPlayer *m_sfxplayer; + QSoundEffect *m_sfxplayer; int m_volume = 0; };