2 Copyright (C) 2010 by Juan Carlos Torres <jucato@kdemail.net>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of
7 the License or (at your option) version 3 or any later version
8 accepted by the membership of KDE e.V. (or its successor appro-
9 ved by the membership of KDE e.V.), which shall act as a proxy
10 defined in Section 14 of version 3 of the license.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see http://www.gnu.org/licenses/.
40 * @brief A simple Phonon-based music player widget
42 * This class implements a very simple widget for playing music
43 * using Phonon. Features include opening a file, playing/pausing,
44 * rewinding, and adjusting the volume.
46 class MusicPlayer : public QWidget
51 MusicPlayer(QWidget* parent = 0, Qt::WindowFlags flags = 0);
52 virtual ~MusicPlayer();
55 * Returns the current volume level.
57 * @return @c qreal Volume level, between 0 and 1.0
63 * Calls a QFileDialog for opening a file, initially
64 * from the platform's Music directory.
69 * Plays or pauses the file currently contained in the
70 * selection. Also updates the player buttons to the
71 * appropriate state. For example, the Play button
72 * displays a pause icon if the file is currently playing,
73 * and a play icon if the file is paused.
75 * @param checked Determines whether to play (@c true) or
76 * pause (@false) the file
78 void playOrPause(bool checked);
81 * Rewinds the current audio file to teh beginning.
86 * Updates the state of the controls in the player depending on
87 * the state of the line edit indicating the audio file to play.
88 * If the line edit is not empty, the controls are enabled. Otherwise
91 * @param filename A string containing the contents of the line edit
93 void enableButtons(QString filename);
96 * Sets the current volume level.
98 * @param volume Volume level, between 0 and 1.0
100 void setVolume(qreal volume);
103 Phonon::MediaObject* m_player;
104 Phonon::AudioOutput* m_audio;
106 QPushButton* m_playButton;
107 QPushButton* m_rewindButton;
112 QLineEdit* m_filenameEdit;