forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cantata-2.0.1-mpris-true.patch
100 lines (97 loc) · 3.85 KB
/
cantata-2.0.1-mpris-true.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Always return true for MPRIS CanPlay, CanPause, etc.
diff --git a/dbus/mpris.cpp b/dbus/mpris.cpp
index 4736d19..45a539a 100644
--- a/dbus/mpris.cpp
+++ b/dbus/mpris.cpp
@@ -65,6 +65,31 @@ Mpris::~Mpris()
QDBusConnection::sessionBus().unregisterService("org.mpris.MediaPlayer2.cantata");
}
+void Mpris::Pause()
+{
+ if (MPDState_Playing==MPDStatus::self()->state()) {
+ StdActions::self()->playPauseTrackAction->trigger();
+ }
+}
+
+void Mpris::Play()
+{
+ MPDStatus * const status = MPDStatus::self();
+ if (status->playlistLength() && MPDState_Playing!=status->state()) {
+ StdActions::self()->playPauseTrackAction->trigger();
+ }
+}
+
+QString Mpris::PlaybackStatus() const
+{
+ switch(MPDStatus::self()->state()) {
+ case MPDState_Playing: return QLatin1String("Playing");
+ case MPDState_Paused: return QLatin1String("Paused");
+ default:
+ case MPDState_Stopped: return QLatin1String("Stopped");
+ }
+}
+
qlonglong Mpris::Position() const
{
// Cant use MPDStatus, as we dont poll for track position, but use a timer instead!
diff --git a/dbus/mpris.h b/dbus/mpris.h
index 64a4fbe..a1578b9 100644
--- a/dbus/mpris.h
+++ b/dbus/mpris.h
@@ -71,37 +71,15 @@ class Mpris : public QObject
// org.mpris.MediaPlayer2.Player
void Next() { StdActions::self()->nextTrackAction->trigger(); }
void Previous() { StdActions::self()->prevTrackAction->trigger(); }
- void Pause() {
- if (MPDState_Playing==MPDStatus::self()->state()) {
- StdActions::self()->playPauseTrackAction->trigger();
- }
- }
-
+ void Pause();
void PlayPause() { StdActions::self()->playPauseTrackAction->trigger(); }
void Stop() { StdActions::self()->stopPlaybackAction->trigger(); }
void StopAfterCurrent() { StdActions::self()->stopAfterCurrentTrackAction->trigger(); }
-
- void Play() {
- MPDStatus * const status = MPDStatus::self();
-
- if (status->playlistLength() && MPDState_Playing!=status->state()) {
- StdActions::self()->playPauseTrackAction->trigger();
- }
- }
-
+ void Play();
void Seek(qlonglong pos) { emit setSeekId(-1, pos/1000000); }
void SetPosition(const QDBusObjectPath &, qlonglong pos) {emit setSeekId(-1, pos/1000000); }
void OpenUri(const QString &) { }
-
- QString PlaybackStatus() {
- switch(MPDStatus::self()->state()) {
- case MPDState_Playing: return QLatin1String("Playing");
- case MPDState_Paused: return QLatin1String("Paused");
- default:
- case MPDState_Stopped: return QLatin1String("Stopped");
- }
- }
-
+ QString PlaybackStatus() const;
QString LoopStatus() { return MPDStatus::self()->repeat() ? QLatin1String("Playlist") : QLatin1String("None"); }
void SetLoopStatus(const QString &s) { emit setRepeat(QLatin1String("None")!=s); }
QVariantMap Metadata() const;
@@ -115,11 +93,11 @@ class Mpris : public QObject
double MinimumRate() const { return 1.0; }
double MaximumRate() const { return 1.0; }
bool CanControl() const { return true; }
- bool CanPlay() const { return MPDState_Playing!=MPDStatus::self()->state() && MPDStatus::self()->playlistLength()>0; }
- bool CanPause() const { return MPDState_Playing==MPDStatus::self()->state(); }
- bool CanSeek() const { return -1!=MPDStatus::self()->songId(); }
- bool CanGoNext() const { return MPDState_Stopped!=MPDStatus::self()->state() && MPDStatus::self()->playlistLength()>1; }
- bool CanGoPrevious() const { return MPDState_Stopped!=MPDStatus::self()->state() && MPDStatus::self()->playlistLength()>1; }
+ bool CanPlay() const { return true; }
+ bool CanPause() const { return true; }
+ bool CanSeek() const { return true; }
+ bool CanGoNext() const { return true; }
+ bool CanGoPrevious() const { return true; }
// org.mpris.MediaPlayer2
bool CanQuit() const { return true; }