aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCerapter <cerap@protonmail.com>2018-09-04 20:39:08 +0200
committerCerapter <cerap@protonmail.com>2018-09-04 20:39:08 +0200
commit1124d6b073546bacd58bce640bbcc08db4f8b341 (patch)
treeea17dff01db072147708543d3cfd757523fae5e2
parentecade0dc13465059c93932fe863aa1e3f1f7e16c (diff)
`QMediaPlayer` instead of `QSoundEffect` for SFX and blips.
Maybe temporary.
-rw-r--r--aoblipplayer.cpp7
-rw-r--r--aoblipplayer.h4
-rw-r--r--aosfxplayer.cpp6
-rw-r--r--aosfxplayer.h4
4 files changed, 11 insertions, 10 deletions
diff --git a/aoblipplayer.cpp b/aoblipplayer.cpp
index 5e3929e2..c58e2cc9 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,17 +17,18 @@ void AOBlipPlayer::set_blips(QString p_sfx)
{
m_sfxplayer->stop();
QString f_path = ao_app->get_sounds_path() + p_sfx.toLower();
- m_sfxplayer->setSource(QUrl::fromLocalFile(f_path));
+ m_sfxplayer->setMedia(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 / 100.0);
+ m_sfxplayer->setVolume(p_value);
}
diff --git a/aoblipplayer.h b/aoblipplayer.h
index c8a8cb6d..b4601962 100644
--- a/aoblipplayer.h
+++ b/aoblipplayer.h
@@ -6,7 +6,7 @@
#include <QWidget>
#include <string.h>
#include <QDebug>
-#include <QSoundEffect>
+#include <QMediaPlayer>
class AOBlipPlayer
{
@@ -23,7 +23,7 @@ public:
private:
QWidget *m_parent;
AOApplication *ao_app;
- QSoundEffect *m_sfxplayer;
+ QMediaPlayer *m_sfxplayer;
int m_volume;
};
diff --git a/aosfxplayer.cpp b/aosfxplayer.cpp
index 972cd749..9089aecb 100644
--- a/aosfxplayer.cpp
+++ b/aosfxplayer.cpp
@@ -4,7 +4,7 @@ AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app)
{
m_parent = parent;
ao_app = p_ao_app;
- m_sfxplayer = new QSoundEffect();
+ m_sfxplayer = new QMediaPlayer(m_parent, QMediaPlayer::Flag::LowLatency);
}
AOSfxPlayer::~AOSfxPlayer()
@@ -26,7 +26,7 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char)
else
f_path = ao_app->get_sounds_path() + p_sfx;
- m_sfxplayer->setSource(QUrl::fromLocalFile(f_path));
+ m_sfxplayer->setMedia(QUrl::fromLocalFile(f_path));
set_volume(m_volume);
m_sfxplayer->play();
@@ -40,5 +40,5 @@ void AOSfxPlayer::stop()
void AOSfxPlayer::set_volume(int p_value)
{
m_volume = p_value;
- m_sfxplayer->setVolume(p_value / 100.0);
+ m_sfxplayer->setVolume(p_value);
}
diff --git a/aosfxplayer.h b/aosfxplayer.h
index 1b73e490..ab9fd979 100644
--- a/aosfxplayer.h
+++ b/aosfxplayer.h
@@ -6,7 +6,7 @@
#include <QWidget>
#include <string.h>
#include <QDebug>
-#include <QSoundEffect>
+#include <QMediaPlayer>
class AOSfxPlayer
{
@@ -21,7 +21,7 @@ public:
private:
QWidget *m_parent;
AOApplication *ao_app;
- QSoundEffect *m_sfxplayer;
+ QMediaPlayer *m_sfxplayer;
int m_volume = 0;
};