Merge pull request #9589 from hyperlogic/bug-fix/tablet-ui-button-click-volume

tablet-ui: reduced volume of button click
This commit is contained in:
Seth Alves 2017-02-01 20:16:38 -08:00 committed by GitHub
commit 0dead3b458
3 changed files with 15 additions and 0 deletions

View file

@ -20,6 +20,7 @@ Item {
SoundEffect {
id: buttonClickSound
volume: 0.1
source: "../../../sounds/Gamemaster-Audio-button-click.wav"
}

View file

@ -23,10 +23,19 @@ void SoundEffect::setSource(QUrl url) {
_sound = DependencyManager::get<SoundCache>()->getSound(_url);
}
float SoundEffect::getVolume() const {
return _volume;
}
void SoundEffect::setVolume(float volume) {
_volume = volume;
}
void SoundEffect::play(QVariant position) {
AudioInjectorOptions options;
options.position = vec3FromVariant(position);
options.localOnly = true;
options.volume = _volume;
if (_injector) {
_injector->setOptions(options);
_injector->restart();

View file

@ -22,6 +22,7 @@ class AudioInjector;
class SoundEffect : public QQuickItem {
Q_OBJECT
Q_PROPERTY(QUrl source READ getSource WRITE setSource)
Q_PROPERTY(float volume READ getVolume WRITE setVolume)
public:
virtual ~SoundEffect();
@ -29,9 +30,13 @@ public:
QUrl getSource() const;
void setSource(QUrl url);
float getVolume() const;
void setVolume(float volume);
Q_INVOKABLE void play(QVariant position);
protected:
QUrl _url;
float _volume { 1.0f };
SharedSoundPointer _sound;
AudioInjector* _injector { nullptr };
};