%
% anyremote configuration file for VLC (http://www.videolan.org/doc/play-howto/en/apb.html)
% management. (Server-mode)
%
% Thanks to Eric (petesahat at sf.net) for the patch
%
% prerequisites: amixer/pactl utility
% 

% STATUS stable
% TODO open DVD works strange
% XTEST yes
% SOUND mixer
% ENV no
% FBROWSER v.3i
% IPC app
% DEF_VIDEO_PLAYER   
% ALL_IN_ONE 

GuiAppName=VLC
GuiAppBinary=vlc
GuiAppRun=echo 'P=`ps -ef|grep vlc|grep -v grep|grep -v anyremote|grep -v edit`; if [ "x$P" == "x" ]; then echo NOK; else echo OK; fi'|bash -f -s
GuiAppIcon=vlc.png
GuiAppType=Application
GuiAppProtocols=Server
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. Control it through http interface.

[Protocol]=Server

(Init)=\
	Include($(CfgDir)/Utils/aliases-server.cfg);\
        Include($(CfgDir)/Utils/aliases-server-fbrowser-v3i.cfg);\
	Include($(CfgDir)/Utils/aliases-server-video-player.cfg);\
	Macro(TEST_QDBUS);\
	Macro(SETUP_DEFAULT_MIXER);\
	Exec(echo 'P=`which wget 2> /dev/null|grep wget|grep -v no|wc -l|tr -d " "`;if [ "x$P" == "x1" ]; then true; else $(CfgDir)/Utils/message.sh "ERROR: wget package is not installed"; fi'|bash -f -s);\
	Make(var,app_name,by_value,VLC/http);\
	Make(var,open_file,by_value,);\
	Make(var,app_manage_mode,by_value,vlc_dbus);\
	Make(var,vlc_dbus,by_value,qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2);

(Connect)=Make(mode,vlc_dbus_init);

[Mode]=vlc_dbus_init : default_video_player_init

APP_IS_RUN=\
	Make(var,app_run,ID=`id -u`;P=`ps -fu $ID|grep vlc|grep -v grep|grep -v anyremote|grep -v edit`; if [ "x$P" = "x" ]; then echo 0; else echo 1; fi);

[ModeEnd]

[Mode]=vlc_dbus : default_video_player

APP_START_IF=\
	Set(title,$(open_file));\
	Exec(ID=`id -u`;P=`ps -fu $ID|grep vlc|grep -v grep|grep -v anyremote|grep -v edit`; if [ "x$P" = "x" ]; then cd "`cat $HOME/.anyRemote/ar_storedir.tmp`"; vlc --control dbus $(open_file) 2> /dev/null& fi);

% Application window should be present in output of "wmctrl -l"
APP_RAISE=\
	Exec($(CfgDir)/Utils/run-or-switch-to.sh -switch vlc);

APP_QUIT=\
	Exec($(vlc_dbus) org.mpris.MediaPlayer2.Quit);

APP_FULLSCREEN=\
	Emulate(key,f);

APP_MENU=\
	Set(menu,replace,Open DVD,Alt-F4,Power Off,Suspend);\
	Macro(ALLIN1MENU);

%Power Off,Suspend by Utils/aliases-server-player.cfg
Open DVD=Macro(QUIT);Exec(vlc --control dbus dvdsimple://);

Alt-F4=Emulate(keydown,Alt_L,key,F4,keyup,Alt_L);

% Volume control and 0-9,*,# assignments by Utils/aliases-server-player.cfg


PLAY =Exec($(vlc_dbus) org.mpris.MediaPlayer2.Player.Play);
PREV =Exec($(vlc_dbus) org.mpris.MediaPlayer2.Player.Previous);
NEXT =Exec($(vlc_dbus) org.mpris.MediaPlayer2.Player.Next);
RWD  =Emulate(keydown,Alt_L,key,Left,keyup,Alt_L);
FF   =Emulate(keydown,Alt_L,key,Right,keyup,Alt_L);
STOP =Exec($(vlc_dbus) org.mpris.MediaPlayer2.Player.Stop);
PAUSE=Exec($(vlc_dbus) org.mpris.MediaPlayer2.Player.Pause)

% no working setpos method
%VLC_GET_POS=\
%	Make(var,vlc_pos,qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Position);
	
[ModeEnd]

[End]
