%
% anyremote configuration file for XMMS management. (Server-mode CommandFusion iViewer emulation)
% prerequisites: Iviewer client installed on Ipod touch/Iphone 2.x and Iviewer free winamp GUI
%

% STATUS stable
% XTEST no
% SOUND app
% ENV no

GuiAppName=Xmms
GuiAppBinary=xmms
GuiAppRun=echo 'P=`ps -ef|grep xmms|grep -v xmms2|grep -v grep|grep -v anyremote|grep -v edit`; if [ "x$P" == "x" ]; then echo NOK; else echo OK; fi' | bash -f -s
GuiAppIcon=xmms.png
GuiAppType=Application
GuiAppProtocols=iViewer
GuiAppDesc=XMMS is a multimedia player for unix systems. XMMS stands for X MultiMedia System and can play media files such as MP3, MOD's, WAV and others with the use of Input plugins.

[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
d1(1)=Exec(xmmsctrl play);

% stop
d30(1)=Exec(xmmsctrl stop);

% pause
d31(1)=Exec(xmmsctrl pause);

% next
d5(1)=Exec(xmmsctrl next);

% prev
d6(1)=Exec(xmmsctrl prev);

% toggle repeat
d12(1)=Exec(xmmsctrl repeat)

% toggle shuffle
d9(1)=Exec(xmmsctrl shuffle)

% volume contol
a1($$)=Make(var,change_vol,echo "$(Index)*1000/65535" |bc -l);\
	Exec(xmmsctrl vol $(change_vol));\
	Macro(VOLUME);

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

% Feedback
PLAYBACK=Send(string,s5=);ExecAndSend(string,xmmsctrl print "%m");Send(bytes,3);\
        Make(var,playback_persent,echo "65535/100*"`xmmsctrl print "%p"|cut -d "%" -f1`|bc);\
        Send(string,a2=$(playback_persent));Send(bytes,3);

% volume 0 - 65535
VOLUME= Make(var,vol_persent,echo "65535/100*"`xmmsctrl print "%v"|cut -d "%" -f1`|bc);\
        Send(string,a1=$(vol_persent));Send(bytes,3);


% Artist name
ARTIST=ExecAndSend(string,xmmsctrl print "%T" | cut -d "-" -f1);

% Track
TRACK =ExecAndSend(string,xmmsctrl print "%T" | cut -d "-" -f2);

% Song length mm:ss
SONG_LEN=ExecAndSend(string,xmmsctrl print "%M");

%
% 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)=Make(var,IViewer,by_value,true);

(Connect)=Timer(DISC,10,1);\
	Timer(PLAYBACK,3,0);\
	Timer(VOLUME,10,0);\
	Timer(TITLE,5,0);

(Disconnect)=Macro(STOP_TIMERS);

[End]

