File indexing completed on 2024-04-21 15:08:24

0001 /***************************************************************************
0002                           csoundplayer.h  -  sound player
0003                              -------------------
0004     begin                : So apr 19 2003
0005     copyright            : (C) 2003-2008 by Tomas Mecir
0006     email                : kmuddy@kmuddy.com
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *                                                                         *
0011  *   This program is free software; you can redistribute it and/or modify  *
0012  *   it under the terms of the GNU General Public License as published by  *
0013  *   the Free Software Foundation; either version 2 of the License, or     *
0014  *   (at your option) any later version.                                   *
0015  *                                                                         *
0016  ***************************************************************************/
0017 
0018 #ifndef CSOUNDPLAYER_H
0019 #define CSOUNDPLAYER_H
0020 
0021 #include <cactionbase.h>
0022 #include <kmuddy_export.h>
0023 
0024 #include <qobject.h>
0025 #include <QMediaPlayer>
0026 
0027 /**
0028 Plays sound via Phonon.
0029   *@author Tomas Mecir
0030   */
0031 
0032 class KMUDDY_EXPORT cSoundPlayer : public QObject, public cActionBase {
0033    Q_OBJECT
0034 public: 
0035   cSoundPlayer (bool isWAVE = true);
0036   // constructor must always be visible as well, else compilation fails
0037   ~cSoundPlayer () override;
0038   /** are we currently playing? */
0039   bool isPlaying ();
0040   /** priority of currently played sound */
0041   int curPriority ();
0042   /** set new priority */
0043   void setPriority (int val);
0044   /** remaining # of repeats, INCLUDING current one */
0045   int remainingRepeats ();
0046   /** set repeats count; will NOT affect playing sound */
0047   void setRepeatsCount (int val);
0048   /** played file name */
0049   QString fileName ();
0050   /** set new file name */
0051   void setFileName (const QString &name);
0052   /** current volume */
0053   int curVolume ();
0054   /** set new volume */
0055   void setVolume (int val);
0056   /** play sound, stopping previous one, if any */
0057   void play ();
0058   /** stop playing */
0059   void stop ();
0060   /** will force updating of some parameters for currently played sound;
0061   this includes repeat count, priority and volume */
0062   void forceUpdateParams ();
0063   void disableSound ();
0064 protected slots:
0065   void stateChanged (QMediaPlayer::State newState);
0066 protected:
0067   void init ();
0068   void finished ();
0069 
0070   struct Private;
0071   Private *d;
0072 };
0073 
0074 #endif