File indexing completed on 2021-12-21 13:33:28
0001 /* 0002 * Kscd - A simple cd player for the KDE Project 0003 * 0004 * Copyright (c) 2008 Amine Bouchikhi <bouchikhi.amine@gmail.com> 0005 * Copyright (c) 2008 Stanislas Krzywda <stanislas.krzywda@gmail.com> 0006 * 0007 * ----------------------------------------------------------------------------- 0008 * 0009 * This program is free software; you can redistribute it and/or modify 0010 * it under the terms of the GNU General Public License as published by 0011 * the Free Software Foundation; either version 2, or (at your option) 0012 * any later version. 0013 * 0014 * This program is distributed in the hope that it will be useful, 0015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 * GNU General Public License for more details. 0018 * 0019 * You should have received a copy of the GNU General Public License 0020 * along with this program; if not, write to the Free Software 0021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0022 * 0023 */ 0024 #ifndef HWCONTROLER 0025 #define HWCONTROLER 0026 0027 #include <QObject> 0028 #include <QList> 0029 #include <QString> 0030 #include <solid/device.h> 0031 #include <solid/opticaldisc.h> 0032 0033 #include <phonon/mediasource.h> 0034 #include <phonon/mediaobject.h> 0035 #include <phonon/mediacontroller.h> 0036 #include <phonon/audiooutput.h> 0037 #include <phonon/volumeslider.h> 0038 0039 #include "audiocd.h" 0040 0041 enum LoopMode 0042 { 0043 NoLoop = 0, 0044 LoopOne = 1, 0045 LoopAll = 2 0046 }; 0047 0048 class HWControler : public QObject 0049 { 0050 0051 Q_OBJECT 0052 0053 private: 0054 0055 // List of Cds inserted 0056 QList<AudioCD *> cdIn; 0057 // Selected Cd to read 0058 int selectedCd; 0059 // List of detected Audio Output on the system 0060 //QList<Phonon::AudioOutput> speakers; 0061 Phonon::AudioOutput * speakers; 0062 // Selected Output to use 0063 int selectedS; 0064 // Control play activity 0065 Phonon::MediaObject *media; 0066 // Control Next/Preview functions 0067 Phonon::MediaController * mc; 0068 0069 // Loop Mode 0070 LoopMode loopState; 0071 0072 Phonon::Path path; 0073 0074 bool random; 0075 0076 bool isEjectAtTheEndOfTheCdActivated; 0077 0078 QList<int> playList; 0079 0080 int posPlayList; 0081 0082 public: 0083 HWControler(); 0084 ~HWControler(); 0085 void selectCd(int cdNum); 0086 void selectSpeaker(int sNum); 0087 void play(int track); 0088 qint64 getTotalTime () const ; 0089 qint64 getRemainingTime ()const ; 0090 qreal getVolume()const ; 0091 void setVolume(qreal vol); 0092 Phonon::State getState()const ; 0093 void setLoopMode(LoopMode lm); 0094 Phonon::MediaObject * getMedia()const ; 0095 Phonon::AudioOutput * getAudioOutPut()const ; 0096 AudioCD* getCD()const ; 0097 QList<unsigned> &getDiscSignature()const ; 0098 int getCurrentTrack()const ; 0099 int getTotalTrack()const ; 0100 bool isDiscValid(); 0101 bool isEjectActivated() const; 0102 int nbCdReader() const; 0103 QString getCdReader(int num)const ; 0104 private: 0105 void loadPlayList(); 0106 int generateNumber(int inter); 0107 void playRand(); 0108 0109 private slots: 0110 void catchCurrentTime(qint64 pos); 0111 void catchTitleChanged(); 0112 0113 public slots: 0114 void replayTrack(qint64 pos); 0115 void replayDisk(); 0116 void configMedia(); 0117 0118 void setEjectActivated(bool b); 0119 0120 void eject(); 0121 void play(); 0122 void nextTrack(); 0123 void prevTrack(); 0124 void stop(bool restart=false); // @param restart, if true restart from the beginning of the disc 0125 void pause(); 0126 void mute(bool mute); 0127 void setRandom(bool b); 0128 0129 0130 signals: 0131 void currentTime (qint64 pos); 0132 void totalTime(qint64 pos); 0133 void trackChanged(); 0134 void cdLoaded(const QString& device); 0135 0136 }; 0137 0138 #endif