% echo next | socat unix-connect:/home/xedar/vlc.socket stdin
% echo get_title | socat -d unix-connect:/home/xedar/vlc.socket stdio
% $(Home)/.vlc/vlc.socket
%
% anyremote configuration file for VLC management. (Server-mode CommandFusion iViewer emulation)
% prerequisites: Iviewer client installed on Ipod touch/Iphone 2.x and Iviewer free winamp GUI
%

% STATUS nonstable
% XTEST no
% SOUND mixer
% ENV no

GuiAppName=VLC
GuiAppBinary=vlc
GuiAppRun=echo 'P=`ps -ef|grep vlc|grep -v grep|grep -v anyremote|grep -v nedit`; if [ "x$P" == "x" ]; then echo NOK; else echo OK; fi'|bash -f -s
GuiAppIcon=vlc.png
GuiAppType=Application
GuiAppProtocols=iViewer
GuiAppDesc=VLC media player is a highly portable multimedia player for various audio and video formats (MPEG-1, MPEG-2, MPEG-4, DivX, mp3, ogg, ...) as well as DVDs, VCDs, and various streaming protocols.

[Protocol]=iViewer

% Init update
%T current title
%M song len mm:ss
%m playback time mm:ss
%p playback time in persents
%S song len sec

%s1 = artist
%s2 = track

%s6 = song length min:sec.
%s5 = current playback in min:sec
%a2 = needs a constent update to. its the seek bar
%a1 = volume

% play/pause
d1(1)=Exec(echo pause | socat unix-connect:/home/xedar/vlc.socket stdin);

% next
d5(1)=Exec(echo next | socat unix-connect:/home/xedar/vlc.socket stdin);

% prev
d6(1)=Exec(echo prev | socat unix-connect:/home/xedar/vlc.socket stdin);

% toggle repeat
d12(1)=Exec(echo repeat | socat unix-connect:/home/xedar/vlc.socket stdin);

% toggle shuffle
d9(1)=Exec(echo random | socat unix-connect:/home/xedar/vlc.socket stdin);

% volume contol
a1($$)=Make(var,default_mixer_value,by_value,$(Index));\
        Macro(DEFAULT_VOLUME_SET);\
	Macro(VOLUME);

% seek >> and <<
a2($$)=Make(var,seek,echo "$(Index)/65535*10*"`xmmsctrl print "%S"`|bc -l);\
        Exec(xmmsctrl time $(seek));

% Feedback
PLAYBACK=Send(string,s5=);ExecAndSend(string,echo get_time | socat -d unix-connect:/home/xedar/vlc.socket stdio);Send(bytes,3);
        Make(var,playback_time,echo get_time | socat -d unix-connect:/home/xedar/vlc.socket stdio);\
        Make(var,playback_length,echo get_length | socat -d unix-connect:/home/xedar/vlc.socket stdio);\
	Make(var,playback,echo "$(playback_time)/$(playblack_length)*65535" `|bc -l);\
	Send(string,a2=$(playback));Send(bytes,3);

% get volume: 0 - 65535
VOLUME=Macro(DEFAULT_VOLUME_GET);\
        Send(string,a1=$(default_mixer_value));Send(bytes,3);

% Artist name
ARTIST=ExecAndSend(string,echo "");

% Track
TRACK =ExecAndSend(string,echo get_title | socat -d unix-connect:/home/xedar/vlc.socket stdio);

% Song length sec
SONG_LEN=ExecAndSend(string,echo get_length | socat -d unix-connect:/home/xedar/vlc.socket stdio);

%
% The following is a common part. In general, it should not be changed.
%

TITLE=\
	Send(string,s1=);Macro(ARTIST);Send(bytes,3);\
	Send(string,s2=);Macro(TRACK);Send(bytes,3);\
	Send(string,s6=);Macro(SONG_LEN);Send(bytes,3);

d5(0)=Macro(TITLE);
d6(0)=Macro(TITLE);

% Init
i(1)=Macro(TITLE);\
	Macro(VOLUME);

% Password p(PASSWORD)"
p($$)=Send(string,p=ok);Send(bytes,3);

% Heartbeat
DISC=Macro(STOP_TIMERS);Make(disconnect);

h(0)=Timer(DISC,reset);

% no needs to send "h=1\03" replay directly because this will be done 
% automatically - that controlled by $(IViewer) variable
% If $(IViewer) variable is not set it needs to use the following command:
% h(0)=Send(bytes,104,61,49,3);Timer(DISC,reset);

STOP_TIMERS=\
	Timer(PLAYBACK,cancel);\
	Timer(VOLUME,cancel);\
	Timer(TITLE,cancel);
	
% Event timers
(Init)=Include($(CfgDir)/Utils/aliases-iviewer.cfg);\
	Macro(SETUP_DEFAULT_MIXER);\
	Make(var,IViewer,by_value,true);

(Connect)= \
	Exec(echo 'P=`ps -ef|grep vlc|grep -v grep|grep -v anyremote|grep -v nedit`; if [ "x$P" == "x" ]; then vlc& fi' |bash -f -s);\
	Timer(DISC,10,1);\
	Timer(PLAYBACK,3,0);\
	Timer(VOLUME,10,0);\
	Timer(TITLE,5,0);
	

(Disconnect)=Macro(STOP_TIMERS);

[End]

