File indexing completed on 2024-04-28 04:32:37

0001 /*
0002     SPDX-FileCopyrightText: 2007 Pino Toscano <pino@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef _OKULAR_AUDIOPLAYER_H_
0008 #define _OKULAR_AUDIOPLAYER_H_
0009 
0010 #include "okularcore_export.h"
0011 
0012 #include <QObject>
0013 
0014 namespace Okular
0015 {
0016 class AudioPlayerPrivate;
0017 class Document;
0018 class Sound;
0019 class SoundAction;
0020 
0021 /**
0022  * @short An audio player.
0023  *
0024  * Singleton utility class to play sounds in documents using the KDE sound
0025  * system.
0026  */
0027 class OKULARCORE_EXPORT AudioPlayer : public QObject
0028 {
0029     Q_OBJECT
0030 
0031 public:
0032     /**
0033      * The state of AudioPlayer
0034      * @since 0.19 (KDE 4.13)
0035      */
0036     enum State {
0037         /**
0038          * The AudioPlayer is playing a audio file.
0039          */
0040         PlayingState,
0041         /**
0042          * The AudioPlayer isn't playing a audio file.
0043          */
0044         StoppedState
0045     };
0046 
0047     ~AudioPlayer() override;
0048 
0049     /**
0050      * Gets the instance of the audio player.
0051      */
0052     static AudioPlayer *instance();
0053 
0054     /**
0055      * Enqueue the specified @p sound for playing, optionally taking more
0056      * information about the playing from the @p soundlink .
0057      */
0058     void playSound(const Sound *sound, const SoundAction *linksound = nullptr);
0059 
0060     /**
0061      * Tell the AudioPlayer to stop all the playbacks.
0062      */
0063     void stopPlaybacks();
0064 
0065     /**
0066      * Return state of sound (playing/stopped)
0067      * @since 0.19 (KDE 4.13)
0068      */
0069     State state() const;
0070 
0071 private:
0072     AudioPlayer();
0073     void resetDocument();
0074     void setDocument(const QUrl &url, Document *document);
0075 
0076     friend class AudioPlayerPrivate;
0077     AudioPlayerPrivate *const d;
0078     friend class Document;
0079 
0080     Q_DISABLE_COPY(AudioPlayer)
0081 };
0082 
0083 }
0084 
0085 #endif