Bug 381271

Summary: Paused music started playing on suspend
Product: [Applications] juk Reporter: Arthur Schiwon <blizzz>
Component: generalAssignee: Kai Uwe Broulik <kde>
Status: RESOLVED FIXED    
Severity: normal CC: coque.couto, kde, mpyne, nate, nortexoid
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 18.04
Sentry Crash Report:

Description Arthur Schiwon 2017-06-16 08:03:17 UTC
Plasma 5.10 introduced the nice feature to pause music on suspend. However, it also works the different way around, at least when using Juk. If Juk is in paused state, suspend will make the music play. Can cause funny moments when waking up the machine.
Comment 1 Nate Graham 2017-06-16 23:08:56 UTC
Paging Dr. Broulik! :)
Comment 2 Kai Uwe Broulik 2017-06-16 23:27:35 UTC
PowerDevil sends the "Pause" command to the player (not PlayPause) which according to MPris spec [1] "If playback is already paused, this has no effect.", so this is a bug in the player, it works fine with e.g. VLC, re-assigning.

[1] https://specifications.freedesktop.org/mpris-spec/latest/Player_Interface.html#Method:Pause
Comment 3 Michael Pyne 2017-06-17 23:27:42 UTC
The following patch should fix.  I'd commit directly but I don't have a KDE 4 dev environment setup, so if someone can test that this work I'd appreciate it, otherwise I can establish one overnight and try again in a bit.

(Yes, I know I need to port JuK to KF5... right now I'm going to try for a mini-sprint in mid-July for this)

diff --git a/playermanager.cpp b/playermanager.cpp
index 6ca08e0..3a2e091 100644
--- a/playermanager.cpp
+++ b/playermanager.cpp
@@ -276,11 +276,7 @@ void PlayerManager::play()
 
 void PlayerManager::pause()
 {
-    if(!m_setup)
-        return;
-
-    if(paused()) {
-        play();
+    if(!m_setup || paused()) {
         return;
     }
Comment 4 Michael D 2018-03-05 03:02:26 UTC
The fix seems not to have made its way into version 17.12.2 which resumes play on resume from suspend.
Comment 5 Michael Pyne 2018-03-06 01:13:58 UTC
Now that you mention it, it didn't make it into any version of JuK because I never got feedback so I forgot about this one. :(
Comment 6 Michael Pyne 2018-03-06 03:00:48 UTC
Git commit 57457aee76ec28a3ed590ff559da60b353864ad6 by Michael Pyne.
Committed on 06/03/2018 at 02:54.
Pushed by mpyne into branch 'master'.

mpris: Don't toggle playback with "Pause".

We already have a separate playPause action for this, both in the MPRIS2
DBus adaptor, and in PlayerManager.

This also fixes playback resuming when the computer is suspended (Plasma
sends the "Pause" command to each media player regardless of whether
it's playing, and JuK incorrectly treats that as a request to toggle
playback).
FIXED-IN:18.04

M  +1    -6    playermanager.cpp

https://commits.kde.org/juk/57457aee76ec28a3ed590ff559da60b353864ad6
Comment 7 Michael D 2018-03-06 16:21:07 UTC
Thanks again!