File indexing completed on 2023-05-30 11:30:48
0001 /** 0002 * Copyright (C) 2004 Scott Wheeler <wheeler@kde.org> 0003 * Copyright (C) 2007 Matthias Kretz <kretz@kde.org> 0004 * Copyright (C) 2008 Michael Pyne <mpyne@kde.org> 0005 * 0006 * This program is free software; you can redistribute it and/or modify it under 0007 * the terms of the GNU General Public License as published by the Free Software 0008 * Foundation; either version 2 of the License, or (at your option) any later 0009 * version. 0010 * 0011 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 0012 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 0013 * PARTICULAR PURPOSE. See the GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License along with 0016 * this program. If not, see <http://www.gnu.org/licenses/>. 0017 */ 0018 0019 #ifndef JUK_PLAYERMANAGER_H 0020 #define JUK_PLAYERMANAGER_H 0021 0022 #include <QObject> 0023 0024 #include "filehandle.h" 0025 0026 #include <Phonon/Global> 0027 #include <Phonon/Path> 0028 0029 class PlaylistInterface; 0030 class QPixmap; 0031 0032 namespace Phonon 0033 { 0034 class AudioOutput; 0035 class MediaObject; 0036 class MediaSource; 0037 } 0038 0039 /** 0040 * This class serves as a proxy to the Player interface and handles managing 0041 * the actions from the top-level mainwindow. 0042 */ 0043 0044 class PlayerManager : public QObject 0045 { 0046 Q_OBJECT 0047 0048 public: 0049 PlayerManager(); 0050 0051 bool playing() const; 0052 bool paused() const; 0053 bool muted() const; 0054 float volume() const; 0055 int status() const; 0056 0057 // These two have been part of the prior public DBus interface so they have 0058 // been retained. You should use the MSecs versions below. These return in units 0059 // of seconds instead. 0060 int totalTime() const; 0061 int currentTime() const; 0062 0063 int totalTimeMSecs() const; 0064 int currentTimeMSecs() const; 0065 0066 bool seekable() const; 0067 //int position() const; 0068 0069 QStringList trackProperties(); 0070 QString trackProperty(const QString &property) const; 0071 QPixmap trackCover(const QString &size) const; 0072 0073 FileHandle playingFile() const; 0074 QString playingString() const; 0075 0076 void setPlaylistInterface(PlaylistInterface *interface); 0077 0078 QString randomPlayMode() const; 0079 0080 public slots: 0081 void play(const FileHandle &file); 0082 void play(const QString &file); 0083 void play(); // start or restart playback 0084 void pause(); 0085 void stop(); 0086 void seek(int seekTime); 0087 //void seekPosition(int position); 0088 void seekForward(); 0089 void seekBack(); 0090 void playPause(); 0091 void forward(); 0092 void back(); 0093 void setVolume(qreal); 0094 void volumeUp(); 0095 void volumeDown(); 0096 void setMuted(bool m); 0097 bool mute(); 0098 0099 void trackHasChanged(const Phonon::MediaSource &newSource); 0100 0101 void setRandomPlayMode(const QString &randomMode); 0102 0103 signals: 0104 void tick(qint64 /* time_msec */); 0105 void totalTimeChanged(qint64 /* time_msec */); 0106 void mutedChanged(bool muted); 0107 void volumeChanged(float volume); 0108 void seeked(int newPos); 0109 void seekableChanged(bool muted); 0110 0111 void signalPlay(); 0112 void signalPause(); 0113 void signalStop(); 0114 void signalItemChanged(const FileHandle &file); 0115 0116 private: 0117 void setupAudio(); 0118 0119 private slots: 0120 void slotFinished(); 0121 void slotLength(qint64); 0122 void slotTick(qint64); 0123 void slotStateChanged(Phonon::State, Phonon::State); 0124 void slotSeekableChanged(bool); 0125 void slotMutedChanged(bool); 0126 0127 private: 0128 FileHandle m_file; 0129 PlaylistInterface *m_playlistInterface; 0130 bool m_muted; 0131 bool m_setup; 0132 0133 static const int m_pollInterval = 800; 0134 0135 Phonon::AudioOutput *m_output; 0136 Phonon::MediaObject *m_media; 0137 Phonon::Path m_audioPath; 0138 }; 0139 0140 #endif 0141 0142 // vim: set et sw=4 tw=0 sta: