]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/commands/cmd_input.cpp
playlist: rename playlist_Pause() to playlist_TogglePause()
[vlc] / modules / gui / skins2 / commands / cmd_input.cpp
index b70ffebd05bb2ec3042e5b2a4e407545dc075b1d..c78c7904100007a4b8d7d1376a9602b3f22e5830 100644 (file)
@@ -5,7 +5,7 @@
  * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
- *          Olivier Teulière <ipkiss@via.ecp.fr>
+ *          Olivier Teulière <ipkiss@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#include <vlc/aout.h>
 #include "cmd_input.hpp"
 #include "cmd_dialogs.hpp"
-
+#include <vlc_input.h>
+#include <vlc_playlist.h>
 
 void CmdPlay::execute()
 {
     playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
     if( pPlaylist == NULL )
-    {
         return;
+
+    // if already playing an input, reset rate to normal speed
+    input_thread_t *pInput = playlist_CurrentInput( pPlaylist );
+    if( pInput )
+    {
+        var_SetFloat( pPlaylist, "rate", 1.0 );
+        vlc_object_release( pInput );
     }
 
-    if( pPlaylist->i_size )
+    playlist_Lock( pPlaylist );
+    const bool b_empty = playlist_IsEmpty( pPlaylist );
+    playlist_Unlock( pPlaylist );
+
+    if( !b_empty )
     {
         playlist_Play( pPlaylist );
     }
     else
     {
         // If the playlist is empty, open a file requester instead
-        CmdDlgFile cmd( getIntf() );
-        cmd.execute();
+        CmdDlgFile( getIntf() ).execute();
     }
 }
 
@@ -51,38 +60,27 @@ void CmdPlay::execute()
 void CmdPause::execute()
 {
     playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
-    if( pPlaylist == NULL )
-    {
-        return;
-    }
-
-    playlist_Pause( pPlaylist );
+    if( pPlaylist != NULL )
+        playlist_TogglePause( pPlaylist );
 }
 
 
 void CmdStop::execute()
 {
     playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
-    if( pPlaylist == NULL )
-    {
-        return;
-    }
-
-    playlist_Stop( pPlaylist );
+    if( pPlaylist != NULL )
+        playlist_Stop( pPlaylist );
 }
 
 
 void CmdSlower::execute()
 {
-    input_thread_t *pInput =
-        (input_thread_t *)vlc_object_find( getIntf(), VLC_OBJECT_INPUT,
-                                           FIND_ANYWHERE );
+    playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
+    input_thread_t *pInput = playlist_CurrentInput( pPlaylist );
+
     if( pInput )
     {
-        vlc_value_t val;
-        val.b_bool = VLC_TRUE;
-
-        var_Set( pInput, "rate-slower", val );
+        var_TriggerCallback( pPlaylist, "rate-slower" );
         vlc_object_release( pInput );
     }
 }
@@ -90,15 +88,12 @@ void CmdSlower::execute()
 
 void CmdFaster::execute()
 {
-    input_thread_t *pInput =
-        (input_thread_t *)vlc_object_find( getIntf(), VLC_OBJECT_INPUT,
-                                           FIND_ANYWHERE );
+    playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
+    input_thread_t *pInput = playlist_CurrentInput( pPlaylist );
+
     if( pInput )
     {
-        vlc_value_t val;
-        val.b_bool = VLC_TRUE;
-
-        var_Set( pInput, "rate-faster", val );
+        var_TriggerCallback( pPlaylist, "rate-faster" );
         vlc_object_release( pInput );
     }
 }
@@ -106,18 +101,18 @@ void CmdFaster::execute()
 
 void CmdMute::execute()
 {
-    aout_VolumeMute( getIntf(), NULL );
+    playlist_MuteToggle( getIntf()->p_sys->p_playlist );
 }
 
 
 void CmdVolumeUp::execute()
 {
-    aout_VolumeUp( getIntf(), 1, NULL );
+    playlist_VolumeUp( getIntf()->p_sys->p_playlist, 1, NULL );
 }
 
 
 void CmdVolumeDown::execute()
 {
-    aout_VolumeDown( getIntf(), 1, NULL );
+    playlist_VolumeDown( getIntf()->p_sys->p_playlist, 1, NULL );
 }