mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 02:36:54 +02:00
Adds AudioDevice mute functionality to ScriptEngine
This commit is contained in:
parent
8c013a84ff
commit
af74fc09b9
4 changed files with 67 additions and 0 deletions
50
examples/audioMuteExample.js
Normal file
50
examples/audioMuteExample.js
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
//
|
||||||
|
// audioMuteExample.js
|
||||||
|
// examples
|
||||||
|
//
|
||||||
|
// Created by Thijs Wenker on 10/31/14.
|
||||||
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// This example shows how to use the AudioDevice mute functions.
|
||||||
|
// Press the MUTE/UNMUTE button to see it function.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
var toggleMuteButton = Overlays.addOverlay("text", {
|
||||||
|
x: 50,
|
||||||
|
y: 50,
|
||||||
|
width: 190,
|
||||||
|
height: 50,
|
||||||
|
backgroundColor: { red: 255, green: 255, blue: 255},
|
||||||
|
color: { red: 255, green: 0, blue: 0},
|
||||||
|
font: {size: 30},
|
||||||
|
topMargin: 10
|
||||||
|
});
|
||||||
|
|
||||||
|
function muteButtonText() {
|
||||||
|
print("Audio Muted: " + AudioDevice.getMuted());
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMuteStateChanged() {
|
||||||
|
Overlays.editOverlay(toggleMuteButton,
|
||||||
|
AudioDevice.getMuted() ? {text: "UNMUTE", leftMargin: 10} : {text: "MUTE", leftMargin: 38});
|
||||||
|
print("Audio Muted: " + AudioDevice.getMuted());
|
||||||
|
}
|
||||||
|
|
||||||
|
function mousePressEvent(event) {
|
||||||
|
if (Overlays.getOverlayAtPoint({x: event.x, y: event.y}) == toggleMuteButton) {
|
||||||
|
AudioDevice.toggleMute()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function scriptEnding() {
|
||||||
|
Overlays.deleteOverlay(toggleMuteButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
onMuteStateChanged();
|
||||||
|
|
||||||
|
AudioDevice.muteToggled.connect(onMuteStateChanged);
|
||||||
|
Controller.mousePressEvent.connect(mousePressEvent);
|
||||||
|
Script.scriptEnding.connect(scriptEnding);
|
|
@ -1966,6 +1966,9 @@ void Application::init() {
|
||||||
connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector,
|
connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector,
|
||||||
&AudioReflector::preProcessOriginalInboundAudio,Qt::DirectConnection);
|
&AudioReflector::preProcessOriginalInboundAudio,Qt::DirectConnection);
|
||||||
|
|
||||||
|
connect(getAudio(), &Audio::muteToggled, AudioDeviceScriptingInterface::getInstance(),
|
||||||
|
&AudioDeviceScriptingInterface::muteToggled, Qt::DirectConnection);
|
||||||
|
|
||||||
// save settings when avatar changes
|
// save settings when avatar changes
|
||||||
connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
|
connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,3 +78,11 @@ void AudioDeviceScriptingInterface::setReverb(bool reverb) {
|
||||||
void AudioDeviceScriptingInterface::setReverbOptions(const AudioEffectOptions* options) {
|
void AudioDeviceScriptingInterface::setReverbOptions(const AudioEffectOptions* options) {
|
||||||
Application::getInstance()->getAudio()->setReverbOptions(options);
|
Application::getInstance()->getAudio()->setReverbOptions(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioDeviceScriptingInterface::toggleMute() {
|
||||||
|
Application::getInstance()->getAudio()->toggleMute();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AudioDeviceScriptingInterface::getMuted() {
|
||||||
|
return Application::getInstance()->getAudio()->getMuted();
|
||||||
|
}
|
||||||
|
|
|
@ -41,6 +41,12 @@ public slots:
|
||||||
void setInputVolume(float volume);
|
void setInputVolume(float volume);
|
||||||
void setReverb(bool reverb);
|
void setReverb(bool reverb);
|
||||||
void setReverbOptions(const AudioEffectOptions* options);
|
void setReverbOptions(const AudioEffectOptions* options);
|
||||||
|
|
||||||
|
bool getMuted();
|
||||||
|
void toggleMute();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void muteToggled();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AudioDeviceScriptingInterface_h
|
#endif // hifi_AudioDeviceScriptingInterface_h
|
||||||
|
|
Loading…
Reference in a new issue