Revert "QMediaPlayer instead of QSoundEffect for SFX and blips."

This reverts commit 1124d6b073.
This commit is contained in:
Cerapter 2018-09-15 01:37:11 +02:00
parent 8006d40d14
commit 3a1d202363
4 changed files with 10 additions and 11 deletions

View File

@ -2,9 +2,9 @@
AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app) AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app)
{ {
m_sfxplayer = new QSoundEffect;
m_parent = parent; m_parent = parent;
ao_app = p_ao_app; ao_app = p_ao_app;
m_sfxplayer = new QMediaPlayer(m_parent, QMediaPlayer::Flag::LowLatency);
} }
AOBlipPlayer::~AOBlipPlayer() AOBlipPlayer::~AOBlipPlayer()
@ -17,18 +17,17 @@ void AOBlipPlayer::set_blips(QString p_sfx)
{ {
m_sfxplayer->stop(); m_sfxplayer->stop();
QString f_path = ao_app->get_sounds_path() + p_sfx.toLower(); 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); set_volume(m_volume);
} }
void AOBlipPlayer::blip_tick() void AOBlipPlayer::blip_tick()
{ {
//m_sfxplayer->stop();
m_sfxplayer->play(); m_sfxplayer->play();
} }
void AOBlipPlayer::set_volume(int p_value) void AOBlipPlayer::set_volume(int p_value)
{ {
m_volume = p_value; m_volume = p_value;
m_sfxplayer->setVolume(p_value); m_sfxplayer->setVolume(p_value / 100.0);
} }

View File

@ -6,7 +6,7 @@
#include <QWidget> #include <QWidget>
#include <string.h> #include <string.h>
#include <QDebug> #include <QDebug>
#include <QMediaPlayer> #include <QSoundEffect>
class AOBlipPlayer class AOBlipPlayer
{ {
@ -23,7 +23,7 @@ public:
private: private:
QWidget *m_parent; QWidget *m_parent;
AOApplication *ao_app; AOApplication *ao_app;
QMediaPlayer *m_sfxplayer; QSoundEffect *m_sfxplayer;
int m_volume; int m_volume;
}; };

View File

@ -5,7 +5,7 @@ AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app)
{ {
m_parent = parent; m_parent = parent;
ao_app = p_ao_app; ao_app = p_ao_app;
m_sfxplayer = new QMediaPlayer(m_parent, QMediaPlayer::Flag::LowLatency); m_sfxplayer = new QSoundEffect();
} }
AOSfxPlayer::~AOSfxPlayer() AOSfxPlayer::~AOSfxPlayer()
@ -38,7 +38,7 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout)
else else
f_path = sound_path; f_path = sound_path;
m_sfxplayer->setMedia(QUrl::fromLocalFile(f_path)); m_sfxplayer->setSource(QUrl::fromLocalFile(f_path));
set_volume(m_volume); set_volume(m_volume);
m_sfxplayer->play(); m_sfxplayer->play();
@ -52,5 +52,5 @@ void AOSfxPlayer::stop()
void AOSfxPlayer::set_volume(int p_value) void AOSfxPlayer::set_volume(int p_value)
{ {
m_volume = p_value; m_volume = p_value;
m_sfxplayer->setVolume(p_value); m_sfxplayer->setVolume(p_value / 100.0);
} }

View File

@ -6,7 +6,7 @@
#include <QWidget> #include <QWidget>
#include <string.h> #include <string.h>
#include <QDebug> #include <QDebug>
#include <QMediaPlayer> #include <QSoundEffect>
class AOSfxPlayer class AOSfxPlayer
{ {
@ -21,7 +21,7 @@ public:
private: private:
QWidget *m_parent; QWidget *m_parent;
AOApplication *ao_app; AOApplication *ao_app;
QMediaPlayer *m_sfxplayer; QSoundEffect *m_sfxplayer;
int m_volume = 0; int m_volume = 0;
}; };