Bug 125761 - kmplayer - need dcop call to determine playback state
Summary: kmplayer - need dcop call to determine playback state
Status: RESOLVED FIXED
Alias: None
Product: kmplayer
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR wishlist
Target Milestone: ---
Assignee: Koos Vriezen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-17 21:35 UTC by Ruben Jenster
Modified: 2006-04-17 23:20 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ruben Jenster 2006-04-17 21:35:42 UTC
Version:            (using KDE KDE 3.5.2)
Installed from:    Gentoo Packages

Hi,

a dcop call for kmplayer to determine current playback state would be very usefull (e. g. for pausing playback before hibernating/suspending the system).

Amarok and Kaffeine have such a dcop call. It's called 'isPlaying'. Since the 'pause' dcop call toggles between play and pause such a dcop call is aditionally needed.
 
I pause amarok in the following way from my suspend script: 

if ps -C amarokapp >/dev/null; then
    STATUS=`dcop amarok player isPlaying`
    [ $STATUS = true ] && run_on_xserver "/dcop amarok player pause"
  fi

Apart from that, there must be something wrong with the pause button & dcop call in 0.9.2_rc1, you have to press/issue it twice to toggle the state.

Regards,
Ruben
Comment 1 Koos Vriezen 2006-04-17 21:53:02 UTC
That double click to resume after paused is fixed just yesterday
Comment 2 Ruben Jenster 2006-04-17 22:12:05 UTC
What about the 'isPlaying' dcop call - will you implement it?

I don't know (maybe you can tell me) why the 'pause' dcop call in amarok and in kaffeine toggles between pause and play, since there also are'play' dcop calls.

In my opintion it would be better to let 'dcop kmplayer-[0-9]* KMediaPlayer pause' only pause playback and not toggle between pause/play. Then 'pause' could be raised without having to check the playback state.
Comment 3 Koos Vriezen 2006-04-17 22:19:36 UTC
SVN commit 530855 by vriezen:

Redo fix r530463, it should trigger on document deferring and not to a 
playable Mrl, because PartBase::pause() calls it on the document. Saves 
adding more postponed events to all kinds of mrls and thus fixing all 
these cases (basically all playlists).
Adding isPlaying DCOP function, use as 
 dcop kmplayer-pid KMediaPlayer pause

BUG: 125761

At your service :-)


 M  +5 -1      kmplayerpartbase.cpp  
 M  +1 -0      kmplayerpartbase.h  


--- trunk/extragear/multimedia/kmplayer/src/kmplayerpartbase.cpp #530854:530855
@@ -817,6 +817,10 @@
     m_view->fullScreen ();
 }
 
+KDE_NO_EXPORT bool PartBase::isPlaying () {
+    return playing ();
+}
+
 KAboutData* PartBase::createAboutData () {
     KMessageBox::error(0L, "createAboutData", "KMPlayer");
     return 0;
@@ -1074,7 +1078,7 @@
     } else if ((new_state == Node::state_deferred ||
                 (old_state == Node::state_deferred &&
                  new_state > Node::state_deferred)) &&
-            elm == m_player->process ()->mrl ().ptr ()) {
+            elm == m_document.ptr ()) {
         m_player->process ()->pause ();
     }
     if (elm->expose () && (new_state == Node::state_activated ||
--- trunk/extragear/multimedia/kmplayer/src/kmplayerpartbase.h #530854:530855
@@ -177,6 +177,7 @@
     virtual unsigned long length (void) const;
 k_dcop:
     void toggleFullScreen ();
+    bool isPlaying ();
 signals:
     void sourceChanged (KMPlayer::Source * old, KMPlayer::Source * nw);
     void sourceDimensionChanged ();
Comment 4 Koos Vriezen 2006-04-17 22:26:25 UTC
Hmm, I missed your last post. Do you mean that ´isPlaying()´ should return false when movie is paused? In the current code, isPlaying() returns whether the backend process is running or not. There is no accounting about paused or playing because it can be too easily go wrong, eg. MPlayer´s own keyboard shortcuts.
If you think that the current code should only return true on ´isPlaying()´ when not paused, than reopen this bug report (though don´t expect me to fix this soon)
Comment 5 Koos Vriezen 2006-04-17 23:20:35 UTC
SVN commit 530869 by vriezen:

Adding a isPlaying() dcop call for the backends, that can be used to 
determine actual playing state (false on not playing or paused). Since 
this is a synchronious call, I rather not use it for the KMediaPlayer 
dcop interface (and this would also have a different meaning when 
backend is MPlayer then)

CCBUG: 125761

It´s better than nothing, so w/
  dcop kxineplayer-pid Backend isPlaying
or
  dcop kgstplayer-pid Backend isPlaying
you could solve it for your case, probably better to do the ´pause()´ 
call on KMediaPlayer interface of kmplayer.


 M  +7 -0      gstplayer.cpp  
 M  +1 -0      kmplayer_backend.h  
 M  +8 -0      xineplayer.cpp  
 M  +4 -0      xvplayer.cpp  


--- trunk/extragear/multimedia/kmplayer/src/gstplayer.cpp #530868:530869
@@ -483,6 +483,13 @@
         callback->errorMessage (0, err);*/
 }
 
+bool Backend::isPlaying () {
+    mutex.lock ();
+    bool b = gst_elm_play && (GST_STATE (gst_elm_play) == GST_STATE_PLAYING);
+    mutex.unlock ();
+    return b;
+}
+
 KGStreamerPlayer::KGStreamerPlayer (int _argc, char ** _argv)
   : QApplication (_argc, _argv, false) {
 }
--- trunk/extragear/multimedia/kmplayer/src/kmplayer_backend.h #530868:530869
@@ -48,6 +48,7 @@
     virtual ASYNC setConfig (QByteArray);
     virtual ASYNC setAudioLang (int, QString);
     virtual ASYNC setSubtitle (int, QString);
+    virtual bool isPlaying ();
 private:
     BackendPrivate * d;
 };
--- trunk/extragear/multimedia/kmplayer/src/xineplayer.cpp #530868:530869
@@ -377,6 +377,14 @@
         callback->errorMessage (0, err);
 }
 
+bool Backend::isPlaying () {
+    mutex.lock ();
+    bool b = (xine_get_status (stream) == XINE_STATUS_PLAY) &&
+        (xine_get_param (stream, XINE_PARAM_SPEED) != XINE_SPEED_PAUSE);
+    mutex.unlock ();
+    return b;
+}
+
 KXinePlayer::KXinePlayer (int _argc, char ** _argv)
   : QApplication (_argc, _argv, false) {
 }
--- trunk/extragear/multimedia/kmplayer/src/xvplayer.cpp #530868:530869
@@ -202,6 +202,10 @@
         callback->errorMessage (0, err);
 }
 
+bool Backend::isPlaying () {
+    return running;
+}
+
 KXVideoPlayer::KXVideoPlayer (int _argc, char ** _argv)
   : QApplication (_argc, _argv, false) {
 }