10#include <QAudioOutput>
12#include <QMediaPlayer>
31 static constexpr const char *
kDefaultAudioPath =
":/Components/Output/Audio/wiredpanda.wav";
34 explicit AudioBox(QGraphicsItem *parent =
nullptr);
42 QString
audio()
const override;
47 void setAudio(
const QString &audioPath)
override;
70 QAudioOutput *m_audioOutput =
nullptr;
72 QMediaPlayer *m_player =
nullptr;
Shared base class for audio output elements (AudioBox and Buzzer).
AudioBox(QGraphicsItem *parent=nullptr)
Constructs an AudioBox element.
void load(QDataStream &stream, SerializationContext &context) override
void stopAudio() override
Stops hardware playback (called from stop() when m_hasOutputDevice is true).
void applyMute() override
Applies the current m_muted state to the hardware backend.
static constexpr const char * kDefaultAudioPath
void save(QDataStream &stream, SerializationOptions options) const override
void applyVolume() override
Applies the current m_volume to the hardware backend.
AudioBox(const AudioBox &other)
Copy-constructs by delegating to the parent item constructor.
void startAudio() override
Starts hardware playback (called from play() when m_hasOutputDevice is true).
void setAudio(const QString &audioPath) override
Sets the audio source to audioPath and reloads the player.
QStringList externalFiles() const override
QString audio() const override
Returns the file path of the currently loaded audio file.
AudioOutputElement(ElementType type, QGraphicsItem *parent=nullptr, float initialVolume=kDefaultVolume)
Bundles all per-deserialization state so that load() overrides receive it through one explicit parame...
Options passed to GraphicElement::save() (and friends); the save-side counterpart of SerializationCon...