[vlc-commits] Expose a function to pause unconditionally instead of toggling

Ludovic Fauvet git at videolan.org
Tue Jan 1 18:39:09 CET 2013


npapi-vlc | branch: master | Ludovic Fauvet <etix at videolan.org> | Fri Dec 28 18:54:49 2012 +0100| [d4fea95169696cb996d883f8d451bae4ed7c2283] | committer: Ludovic Fauvet

Expose a function to pause unconditionally instead of toggling

See #4805

> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=d4fea95169696cb996d883f8d451bae4ed7c2283
---

 activex/axvlc_idl.h         |   14 ++++++++++++++
 activex/vlccontrol2.cpp     |    8 +++++++-
 activex/vlccontrol2.h       |    1 +
 common/vlc_player.cpp       |    8 ++++++++
 common/vlc_player.h         |    1 +
 npapi/control/npolibvlc.cpp |   12 +++++++++++-
 npapi/vlcplugin_base.h      |    8 ++++----
 npapi/vlcplugin_gtk.cpp     |    2 +-
 8 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/activex/axvlc_idl.h b/activex/axvlc_idl.h
index 1e1f44e..49afb2d 100644
--- a/activex/axvlc_idl.h
+++ b/activex/axvlc_idl.h
@@ -1486,6 +1486,9 @@ interface IVLCPlaylist : public IDispatch
     virtual HRESULT STDMETHODCALLTYPE playItem(
         long itemId) = 0;
 
+    virtual HRESULT STDMETHODCALLTYPE pause(
+        ) = 0;
+
     virtual HRESULT STDMETHODCALLTYPE togglePause(
         ) = 0;
 
@@ -1577,6 +1580,9 @@ typedef struct IVLCPlaylistVtbl {
         IVLCPlaylist* This,
         long itemId);
 
+    HRESULT (STDMETHODCALLTYPE *pause(
+        IVLCPlaylist* This);
+
     HRESULT (STDMETHODCALLTYPE *togglePause)(
         IVLCPlaylist* This);
 
@@ -1622,6 +1628,7 @@ interface IVLCPlaylist {
 #define IVLCPlaylist_add(This,uri,name,options,itemId) (This)->lpVtbl->add(This,uri,name,options,itemId)
 #define IVLCPlaylist_play(This) (This)->lpVtbl->play(This)
 #define IVLCPlaylist_playItem(This,itemId) (This)->lpVtbl->playItem(This,itemId)
+#define IVLCPlaylist_pause(This) (This)->lpVtbl->pause(This)
 #define IVLCPlaylist_togglePause(This) (This)->lpVtbl->togglePause(This)
 #define IVLCPlaylist_stop(This) (This)->lpVtbl->stop(This)
 #define IVLCPlaylist_next(This) (This)->lpVtbl->next(This)
@@ -1675,6 +1682,13 @@ void __RPC_STUB IVLCPlaylist_playItem_Stub(
     IRpcChannelBuffer* pRpcChannelBuffer,
     PRPC_MESSAGE pRpcMessage,
     DWORD* pdwStubPhase);
+HRESULT STDMETHODCALLTYPE IVLCPlaylist_pause_Proxy(
+    IVLCPlaylist* This);
+void __RPC_STUB IVLCPlaylist_pause_Stub(
+    IRpcStubBuffer* This,
+    IRpcChannelBuffer* pRpcChannelBuffer,
+    PRPC_MESSAGE pRpcMessage,
+    DWORD* pdwStubPhase);
 HRESULT STDMETHODCALLTYPE IVLCPlaylist_togglePause_Proxy(
     IVLCPlaylist* This);
 void __RPC_STUB IVLCPlaylist_togglePause_Stub(
diff --git a/activex/vlccontrol2.cpp b/activex/vlccontrol2.cpp
index 4dd05d9..ab88cd8 100644
--- a/activex/vlccontrol2.cpp
+++ b/activex/vlccontrol2.cpp
@@ -557,12 +557,18 @@ STDMETHODIMP VLCPlaylist::playItem(long item)
     return S_OK;
 };
 
-STDMETHODIMP VLCPlaylist::togglePause()
+STDMETHODIMP VLCPlaylist::pause()
 {
     Instance()->get_player().pause();
     return S_OK;
 };
 
+STDMETHODIMP VLCPlaylist::togglePause()
+{
+    Instance()->get_player().togglePause();
+    return S_OK;
+};
+
 STDMETHODIMP VLCPlaylist::stop()
 {
     Instance()->get_player().stop();
diff --git a/activex/vlccontrol2.h b/activex/vlccontrol2.h
index cf25258..b285b4d 100644
--- a/activex/vlccontrol2.h
+++ b/activex/vlccontrol2.h
@@ -267,6 +267,7 @@ public:
     STDMETHODIMP add(BSTR, VARIANT, VARIANT, long*);
     STDMETHODIMP play();
     STDMETHODIMP playItem(long);
+    STDMETHODIMP pause();
     STDMETHODIMP togglePause();
     STDMETHODIMP stop();
     STDMETHODIMP next();
diff --git a/common/vlc_player.cpp b/common/vlc_player.cpp
index 2b07155..1fce04e 100644
--- a/common/vlc_player.cpp
+++ b/common/vlc_player.cpp
@@ -195,6 +195,14 @@ bool vlc_player::play(unsigned int idx)
 void vlc_player::pause()
 {
     if( is_open() ) {
+        libvlc_media_player_set_pause(_mp, true);
+        on_player_action(pa_pause);
+    }
+}
+
+void vlc_player::togglePause()
+{
+    if( is_open() ) {
         libvlc_media_list_player_pause(_ml_p);
         on_player_action(pa_pause);
     }
diff --git a/common/vlc_player.h b/common/vlc_player.h
index 3892511..348c3c9 100644
--- a/common/vlc_player.h
+++ b/common/vlc_player.h
@@ -58,6 +58,7 @@ public:
     void play();
     bool play(unsigned int idx);
     void pause();
+    void togglePause();
     void stop();
 
     bool next();
diff --git a/npapi/control/npolibvlc.cpp b/npapi/control/npolibvlc.cpp
index d40a869..e024c81 100644
--- a/npapi/control/npolibvlc.cpp
+++ b/npapi/control/npolibvlc.cpp
@@ -876,6 +876,7 @@ const NPUTF8 * const LibvlcPlaylistNPObject::methodNames[] =
     "add",
     "play",
     "playItem",
+    "pause",
     "togglePause",
     "stop",
     "next",
@@ -890,6 +891,7 @@ enum LibvlcPlaylistNPObjectMethodIds
     ID_playlist_add,
     ID_playlist_play,
     ID_playlist_playItem,
+    ID_playlist_pause,
     ID_playlist_togglepause,
     ID_playlist_stop,
     ID_playlist_next,
@@ -1013,7 +1015,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
                     return INVOKERESULT_NO_ERROR;
                 }
                 return INVOKERESULT_NO_SUCH_METHOD;
-            case ID_playlist_togglepause:
+            case ID_playlist_pause:
                 if( argCount == 0 )
                 {
                     p_plugin->playlist_pause();
@@ -1021,6 +1023,14 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
                     return INVOKERESULT_NO_ERROR;
                 }
                 return INVOKERESULT_NO_SUCH_METHOD;
+            case ID_playlist_togglepause:
+                if( argCount == 0 )
+                {
+                    p_plugin->playlist_togglePause();
+                    VOID_TO_NPVARIANT(result);
+                    return INVOKERESULT_NO_ERROR;
+                }
+                return INVOKERESULT_NO_SUCH_METHOD;
             case ID_playlist_stop:
                 if( argCount == 0 )
                 {
diff --git a/npapi/vlcplugin_base.h b/npapi/vlcplugin_base.h
index a7441f2..c9f6eb8 100644
--- a/npapi/vlcplugin_base.h
+++ b/npapi/vlcplugin_base.h
@@ -97,10 +97,6 @@ public:
     int      b_stream;
     char *   psz_target;
 
-    void playlist_toggle_play_pause()
-    {
-        playlist_isplaying() ? playlist_pause() : playlist_play();
-    }
     void playlist_play()
     {
         get_player().play();
@@ -125,6 +121,10 @@ public:
     {
         get_player().pause();
     }
+    void playlist_togglePause()
+    {
+        get_player().togglePause();
+    }
     int playlist_isplaying()
     {
         return get_player().is_playing();
diff --git a/npapi/vlcplugin_gtk.cpp b/npapi/vlcplugin_gtk.cpp
index 2e13de0..80b2e0e 100644
--- a/npapi/vlcplugin_gtk.cpp
+++ b/npapi/vlcplugin_gtk.cpp
@@ -365,7 +365,7 @@ static gboolean fullscreen_win_keypress_handler(GtkWidget *widget, GdkEventKey *
     switch (event->keyval)
     {
     case GDK_KEY_space:
-        plugin->playlist_toggle_play_pause();
+        plugin->playlist_togglePause();
         return True;
     case GDK_KEY_Escape:
         plugin->set_fullscreen(false);



More information about the vlc-commits mailing list