2 * Copyright 2007 Alex Merry <alex.merry@kdemail.net>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License version 2 as
6 * published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU Library General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include <juk_interface.h>
26 JukFactory::JukFactory(QObject
* parent
)
27 : DBusPlayerFactory(parent
)
29 setObjectName("JukFactory");
32 Player::Ptr
JukFactory::create(const QVariantList
& args
)
36 Juk
* player
= new Juk(this);
37 if (!player
->isRunning()) {
41 return Player::Ptr(player
);
44 bool JukFactory::matches(const QString
& serviceName
)
46 return serviceName
== "org.kde.juk";
53 Juk::Juk(PlayerFactory
* factory
)
55 jukPlayer(new JukPlayer("org.kde.juk", "/Player",
56 QDBusConnection::sessionBus()))
68 if (!jukPlayer
->isValid()) {
70 jukPlayer
= new JukPlayer("org.kde.juk", "/Player",
71 QDBusConnection::sessionBus());
73 return jukPlayer
->isValid();
76 Player::State
Juk::state()
78 if (jukPlayer
->isValid()) {
79 if (jukPlayer
->playing()) {
82 if (jukPlayer
->paused()) {
91 if (jukPlayer
->isValid()) {
92 return jukPlayer
->trackProperty("Artist");
99 if (jukPlayer
->isValid()) {
100 return jukPlayer
->trackProperty("Album");
107 if (jukPlayer
->isValid()) {
108 return jukPlayer
->trackProperty("Title");
113 int Juk::trackNumber()
115 if (jukPlayer
->isValid()) {
116 return jukPlayer
->trackProperty("Track").value().toInt();
121 QString
Juk::comment()
123 if (jukPlayer
->isValid()) {
124 return jukPlayer
->trackProperty("Comment");
131 if (jukPlayer
->isValid()) {
132 return jukPlayer
->trackProperty("Genre");
139 if (jukPlayer
->isValid()) {
140 return jukPlayer
->totalTime();
147 if (jukPlayer
->isValid()) {
148 return jukPlayer
->currentTime();
155 if (jukPlayer
->isValid()) {
156 return jukPlayer
->volume();
163 if (jukPlayer
->isValid()) {
170 if (jukPlayer
->isValid()) {
177 if (jukPlayer
->isValid()) {
184 if (jukPlayer
->isValid()) {
191 if (jukPlayer
->isValid()) {
192 jukPlayer
->forward();
196 void Juk::setVolume(qreal volume
) {
197 if (jukPlayer
->isValid()) {
198 jukPlayer
->setVolume(volume
);
202 void Juk::seek(int time
)
204 if (jukPlayer
->isValid()) {
205 // jukPlayer->seek() wants milliseconds
206 jukPlayer
->seek(time
* 1000);