QMediaPlayer
instead of QSoundEffect
for SFX and blips.
Maybe temporary.
This commit is contained in:
parent
ecade0dc13
commit
1124d6b073
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user