mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-08 23:12:16 +02:00
Merge pull request #3732 from thoys/20166
CR for Job #20166 - Extend AudioDeviceScriptingInterface to have muted property and mute event
This commit is contained in:
commit
583b7b1267
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);
|
|
@ -1980,6 +1980,9 @@ void Application::init() {
|
|||
connect(getAudio(), &Audio::preProcessOriginalInboundAudio, &_audioReflector,
|
||||
&AudioReflector::preProcessOriginalInboundAudio,Qt::DirectConnection);
|
||||
|
||||
connect(getAudio(), &Audio::muteToggled, AudioDeviceScriptingInterface::getInstance(),
|
||||
&AudioDeviceScriptingInterface::muteToggled, Qt::DirectConnection);
|
||||
|
||||
// save settings when avatar changes
|
||||
connect(_myAvatar, &MyAvatar::transformChanged, this, &Application::bumpSettings);
|
||||
}
|
||||
|
|
|
@ -78,3 +78,11 @@ void AudioDeviceScriptingInterface::setReverb(bool reverb) {
|
|||
void AudioDeviceScriptingInterface::setReverbOptions(const AudioEffectOptions* 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 setReverb(bool reverb);
|
||||
void setReverbOptions(const AudioEffectOptions* options);
|
||||
|
||||
bool getMuted();
|
||||
void toggleMute();
|
||||
|
||||
signals:
|
||||
void muteToggled();
|
||||
};
|
||||
|
||||
#endif // hifi_AudioDeviceScriptingInterface_h
|
||||
|
|
Loading…
Reference in a new issue