2 * Copyright 2008 Alex Merry <alex.merry@kdemail.net>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301 USA
20 #include "playeractionjob.h"
24 void PlayerActionJob::start()
26 kDebug() << "Trying to perform the action" << operationName();
28 setErrorText(i18n("The player '%1' cannot be found", destination()));
34 const QString
operation(operationName());
35 if (operation
== "play") {
36 if (m_player
->canPlay()) {
39 setErrorText(i18n("The player '%1' cannot perform the action 'play'", m_player
->name()));
42 } else if (operation
== "pause") {
43 if (m_player
->canPause()) {
46 setErrorText(i18n("The player '%1' cannot perform the action 'pause'", m_player
->name()));
49 } else if (operation
== "stop") {
50 if (m_player
->canStop()) {
53 setErrorText(i18n("The player '%1' cannot perform the action 'stop'", m_player
->name()));
56 } else if (operation
== "previous") {
57 if (m_player
->canGoPrevious()) {
60 setErrorText(i18n("The player '%1' cannot perform the action 'previous'", m_player
->name()));
63 } else if (operation
== "next") {
64 if (m_player
->canGoNext()) {
67 setErrorText(i18n("The player '%1' cannot perform the action 'next'", m_player
->name()));
70 } else if (operation
== "volume") {
71 if (m_player
->canSetVolume()) {
72 if (parameters().contains("level")) {
73 qreal volume
= parameters()["level"].toDouble();
74 if (volume
>= 0.0 && volume
<= 1.0) {
75 m_player
->setVolume(volume
);
77 setErrorText(i18n("The 'level' argument to the 'volume' command must be between 0 and 1"));
81 setErrorText(i18n("The 'volume' command requires a 'level' argument"));
85 setErrorText(i18n("The player '%1' cannot perform the action 'volume'", m_player
->name()));
88 } else if (operation
== "seek") {
89 if (m_player
->canSeek()) {
90 if (parameters().contains("seconds")) {
91 qreal time
= parameters()["seconds"].toInt();
92 if (time
>= 0 && time
<= m_player
->length()) {
95 setErrorText(i18n("The 'seconds' argument to the 'seek' command must be "
96 "between 0 and the length of the track"));
100 setErrorText(i18n("The 'seek' command requires a 'seconds' argument"));
104 setErrorText(i18n("The player '%1' cannot perform the action 'seek'", m_player
->name()));
109 kDebug() << "Failed with error" << errorText();
114 #include "playeractionjob.moc"
116 // vim: sw=4 sts=4 et tw=100