From 0876b490c4b19828e7edd62939d991168779b0c5 Mon Sep 17 00:00:00 2001 From: Cyril Deguet Date: Sat, 3 Apr 2004 09:21:12 +0000 Subject: [PATCH] * all: support of shuffle from the skins2 interface: - created a bool variable "playlist.isRandom" and 2 commands "playlist.setRandom(true)" and "playlist.setRandom(false)" - known bug: the playlist doesn't scroll automatically when the stream changes --- modules/gui/skins2/commands/cmd_playlist.cpp | 17 ++++++++++++++- modules/gui/skins2/commands/cmd_playlist.hpp | 22 +++++++++++++++++++- modules/gui/skins2/parser/interpreter.cpp | 4 ++++ modules/gui/skins2/src/vlcproc.cpp | 7 +++++++ modules/gui/skins2/src/vlcproc.hpp | 4 ++++ 5 files changed, 52 insertions(+), 2 deletions(-) diff --git a/modules/gui/skins2/commands/cmd_playlist.cpp b/modules/gui/skins2/commands/cmd_playlist.cpp index 488ff55e03..7382268300 100755 --- a/modules/gui/skins2/commands/cmd_playlist.cpp +++ b/modules/gui/skins2/commands/cmd_playlist.cpp @@ -2,7 +2,7 @@ * cmd_playlist.cpp ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: cmd_playlist.cpp,v 1.2 2004/01/10 03:36:03 hartman Exp $ + * $Id$ * * Authors: Cyril Deguet * Olivier Teulière @@ -23,6 +23,8 @@ *****************************************************************************/ #include "cmd_playlist.hpp" +#include "../src/vlcproc.hpp" +#include "../utils/var_bool.hpp" void CmdPlaylistDel::execute() @@ -61,3 +63,16 @@ void CmdPlaylistPrevious::execute() playlist_Prev( pPlaylist ); } } + + +void CmdPlaylistRandom::execute() +{ + playlist_t *pPlaylist = getIntf()->p_sys->p_playlist; + if( pPlaylist != NULL ) + { + vlc_value_t val; + val.b_bool = m_value; + var_Set( pPlaylist , "random", val); + } +} + diff --git a/modules/gui/skins2/commands/cmd_playlist.hpp b/modules/gui/skins2/commands/cmd_playlist.hpp index 9a68c65d01..a1ff8aa4e4 100755 --- a/modules/gui/skins2/commands/cmd_playlist.hpp +++ b/modules/gui/skins2/commands/cmd_playlist.hpp @@ -2,7 +2,7 @@ * cmd_playlist.hpp ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: cmd_playlist.hpp,v 1.1 2004/01/03 23:31:33 asmax Exp $ + * $Id$ * * Authors: Cyril Deguet * Olivier Teulière @@ -59,4 +59,24 @@ DEFINE_COMMAND( PlaylistNext, "playlist next" ) DEFINE_COMMAND( PlaylistPrevious, "playlist previous" ) +/// Command to set the random state +class CmdPlaylistRandom: public CmdGeneric +{ + public: + CmdPlaylistRandom( intf_thread_t *pIntf, bool value ): + CmdGeneric( pIntf ), m_value( value ) {} + virtual ~CmdPlaylistRandom() {} + + /// This method does the real job of the command + virtual void execute(); + + /// Return the type of the command + virtual string getType() const { return "playlist random"; } + + private: + /// Random state + bool m_value; +}; + + #endif diff --git a/modules/gui/skins2/parser/interpreter.cpp b/modules/gui/skins2/parser/interpreter.cpp index c7088a4a8f..62edf3c86a 100644 --- a/modules/gui/skins2/parser/interpreter.cpp +++ b/modules/gui/skins2/parser/interpreter.cpp @@ -59,6 +59,10 @@ Interpreter::Interpreter( intf_thread_t *pIntf ): SkinObject( pIntf ) REGISTER_CMD( "playlist.next()", CmdPlaylistNext ) REGISTER_CMD( "playlist.previous()", CmdPlaylistPrevious ) REGISTER_CMD( "playlist.sort()", CmdPlaylistSort ) + m_commandMap["playlist.setRandom(true)"] = + CmdGenericPtr( new CmdPlaylistRandom( getIntf(), true ) ); + m_commandMap["playlist.setRandom(false)"] = + CmdGenericPtr( new CmdPlaylistRandom( getIntf(), false ) ); REGISTER_CMD( "vlc.fullscreen()", CmdFullscreen ) REGISTER_CMD( "vlc.play()", CmdPlay ) REGISTER_CMD( "vlc.pause()", CmdPause ) diff --git a/modules/gui/skins2/src/vlcproc.cpp b/modules/gui/skins2/src/vlcproc.cpp index 47bb53ab06..52da3f38d6 100755 --- a/modules/gui/skins2/src/vlcproc.cpp +++ b/modules/gui/skins2/src/vlcproc.cpp @@ -71,6 +71,7 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ) REGISTER_VAR( m_cPlaylist, Playlist, "playlist" ) pVarManager->registerVar( getPlaylistVar().getPositionVarPtr(), "playlist.slider" ); + REGISTER_VAR( m_cVarRandom, VarBoolImpl, "playlist.isRandom" ) REGISTER_VAR( m_cVarTime, Time, "time" ) REGISTER_VAR( m_cVarVolume, Volume, "volume" ) REGISTER_VAR( m_cVarStream, Stream, "stream" ) @@ -123,6 +124,7 @@ void VlcProc::manage() VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get(); VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get(); VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get(); + VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get(); // Refresh sound volume audio_volume_t volume; @@ -177,6 +179,11 @@ void VlcProc::manage() pVarSeekable->set( false ); pTime->set( 0, false ); } + + // Refresh the random variable + vlc_value_t val; + var_Get( getIntf()->p_sys->p_playlist, "random", &val ); + pVarRandom->set( val.b_bool ); } diff --git a/modules/gui/skins2/src/vlcproc.hpp b/modules/gui/skins2/src/vlcproc.hpp index ef8873b106..1d1ea4e46a 100755 --- a/modules/gui/skins2/src/vlcproc.hpp +++ b/modules/gui/skins2/src/vlcproc.hpp @@ -48,6 +48,9 @@ class VlcProc: public SkinObject /// Getter for the playlist variable Playlist &getPlaylistVar() { return *((Playlist*)m_cPlaylist.get()); } + /// Getter for the random variable + VarBool &getIsRandomVar() { return *((VarBool*)m_cVarRandom.get()); } + /// Getter for the time variable Time &getTimeVar() { return *((Time*)(m_cVarTime.get())); } @@ -82,6 +85,7 @@ class VlcProc: public SkinObject OSTimer *m_pTimer; /// Playlist variable VariablePtr m_cPlaylist; + VariablePtr m_cVarRandom; /// Variable for current position of the stream VariablePtr m_cVarTime; /// Variable for audio volume -- 2.39.2