7#include <QMediaDevices>
20 static const bool hasOutputDevice = !QMediaDevices::defaultAudioOutput().description().isEmpty();
31 const Status inputValue =
inputs().constFirst()->status();
33 (inputValue == Status::Active) ?
play() :
stop();
Shared base class for audio output elements (AudioBox and Buzzer).
Enums::ElementType ElementType
Port classes: Port (base), InputPort, and OutputPort.
bool isMuted() const
Returns true if audio output is muted.
virtual void startAudio()=0
Starts hardware playback (called from play() when m_hasOutputDevice is true).
float volume() const override
Returns the audio playback volume (0.0–1.0).
void mute(const bool mute=true)
Mutes or unmutes audio according to mute.
void refresh() override
Refreshes the visual appearance based on the current input state.
bool isPlaying() const
Returns true if audio is currently playing.
void setVolume(float vol) override
Sets the audio playback volume to vol (0.0–1.0).
virtual void applyVolume()=0
Applies the current m_volume to the hardware backend.
AudioOutputElement(ElementType type, QGraphicsItem *parent=nullptr, float initialVolume=kDefaultVolume)
virtual void stopAudio()=0
Stops hardware playback (called from stop() when m_hasOutputDevice is true).
virtual void applyMute()=0
Applies the current m_muted state to the hardware backend.
GraphicElement(ElementType type, QGraphicsItem *parent=nullptr)
Constructs a graphic element of the given type, fetching all properties from the metadata registry.
void setLabelAnchor(const QPointF &pos)
void setPixmap(const QString &pixmapPath)
Loads and applies the pixmap located at pixmapPath.
bool isValid()
Returns true if the element is fully initialised and connected correctly.
int type() const override
Returns the custom type identifier for this item.
const QVector< InputPort * > & inputs() const
Returns a const reference to the vector of all input ports.