File indexing completed on 2024-05-12 05:14:51
0001 /* 0002 * messagedisplayhelper_p.h - private declarations for MessageDisplayHelper 0003 * Program: kalarm 0004 * SPDX-FileCopyrightText: 2009-2022 David Jarvie <djarvie@kde.org> 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #pragma once 0010 0011 #include <phonon/phononnamespace.h> 0012 #include <phonon/Path> 0013 #include <QObject> 0014 #include <QMutex> 0015 0016 class MessageDisplayHelper; 0017 0018 namespace Phonon 0019 { 0020 class MediaObject; 0021 class AudioOutput; 0022 class VolumeFaderEffect; 0023 } 0024 0025 // Class to play an audio file, optionally repeated. 0026 class AudioPlayer : public QObject 0027 { 0028 Q_OBJECT 0029 public: 0030 AudioPlayer(const QString& audioFile, float volume, float fadeVolume, int fadeSeconds, int repeatPause); 0031 ~AudioPlayer() override; 0032 void execute(); 0033 QString error() const; 0034 0035 public Q_SLOTS: 0036 void stop(); 0037 0038 Q_SIGNALS: 0039 void readyToPlay(); 0040 0041 private Q_SLOTS: 0042 void checkAudioPlay(); 0043 void playStateChanged(Phonon::State); 0044 0045 private: 0046 void removeEffects(); 0047 0048 mutable QMutex mMutex; 0049 QString mFile; 0050 float mVolume; 0051 float mFadeVolume; 0052 int mFadeSeconds; 0053 int mRepeatPause; 0054 Phonon::MediaObject* mAudioObject {nullptr}; 0055 Phonon::Path mPath; 0056 Phonon::AudioOutput* mAudioOutput {nullptr}; 0057 Phonon::VolumeFaderEffect* mFader {nullptr}; 0058 QString mError; 0059 bool mPlayedOnce; // the sound file has started playing at least once 0060 bool mPausing; // currently pausing between repeats 0061 bool mStopping {false}; // the player is about to be deleted 0062 }; 0063 0064 // vim: et sw=4: