Qmmp
|
00001 /*************************************************************************** 00002 * Copyright (C) 2006-2017 by Ilya Kotov * 00003 * forkotov02@hotmail.ru * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 00019 ***************************************************************************/ 00020 #ifndef SOUNDCORE_H 00021 #define SOUNDCORE_H 00022 00023 #include <QObject> 00024 #include <QString> 00025 #include <QQueue> 00026 #include <QHash> 00027 #include "decoder.h" 00028 #include "output.h" 00029 #include "visual.h" 00030 #include "qmmp.h" 00031 #include "qmmpsettings.h" 00032 #include "eqsettings.h" 00033 00034 class VolumeControl; 00035 class AbstractEngine; 00036 class InputSource; 00037 class StateHandler; 00038 00042 class SoundCore : public QObject 00043 { 00044 Q_OBJECT 00045 public: 00050 SoundCore(QObject *parent = 0); 00054 ~SoundCore(); 00058 qint64 totalTime() const; 00062 EqSettings eqSettings() const; 00066 void setEqSettings(const EqSettings &settings); 00070 int leftVolume() const; 00074 int rightVolume() const; 00078 int volume() const; 00082 int balance() const; 00086 bool isMuted() const; 00090 qint64 elapsed() const; 00094 int bitrate() const; 00098 quint32 frequency() const; 00102 int sampleSize() const; 00106 int channels() const; 00110 Qmmp::State state() const; 00114 QMap <Qmmp::MetaData, QString> metaData() const; 00118 QString metaData(Qmmp::MetaData key) const; 00122 QHash<QString, QString> streamInfo() const; 00127 bool nextTrackAccepted() const; 00131 static SoundCore* instance(); 00132 00133 public slots: 00139 void setVolume(int left, int right); 00144 void setMuted(bool mute); 00148 void changeVolume(int delta); 00153 void setVolume(int volume); 00157 void volumeUp(); 00161 void volumeDown(); 00166 void setBalance(int balance); 00172 bool play(const QString &source, bool queue = false, qint64 offset = -1); 00176 void stop(); 00180 void pause(); 00184 void seek(qint64 pos); 00188 const QString url() const; 00189 00190 signals: 00195 void bufferingProgress(int progress); 00200 void elapsedChanged(qint64 time); 00205 void bitrateChanged(int bitrate); 00210 void frequencyChanged(quint32 frequency); 00215 void sampleSizeChanged(int size); 00220 void channelsChanged(int channels); 00224 void metaDataChanged (); 00228 void streamInfoChanged(); 00232 void stateChanged (Qmmp::State newState); 00236 void finished(); 00242 void volumeChanged(int left, int right); 00247 void mutedChanged(bool muted); 00252 void volumeChanged(int volume); 00257 void balanceChanged(int balance); 00261 void eqSettingsChanged(); 00265 void nextTrackRequest(); 00266 00267 private slots: 00268 void startNextSource(); 00269 void startNextEngine(); 00270 00271 private: 00272 bool event(QEvent *e); 00273 enum NextEngineState 00274 { 00275 NO_ENGINE = 0, 00276 SAME_ENGINE, 00277 ANOTHER_ENGINE, 00278 INVALID_SOURCE 00279 }; 00280 QMap <Qmmp::MetaData, QString> m_metaData; 00281 QHash <QString, QString> m_streamInfo; 00282 QString m_url; 00283 static SoundCore* m_instance; 00284 StateHandler *m_handler; 00285 VolumeControl *m_volumeControl; 00286 AbstractEngine *m_engine; 00287 QQueue<InputSource *> m_sources; 00288 int m_nextState; 00289 bool m_muted; 00290 }; 00291 00292 #endif