%
% 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.4i
% IPC app
% DEF_VIDEO_PLAYER   
% ALL_IN_ONE 
% MEDIACENTER video

GuiAppName=VLC
GuiAppBinary=vlc
GuiAppRun= 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
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);\
	Macro(SETUP_DEFAULT_MIXER);\
	Macro(TEST_QDBUS);\
    Include($(CfgDir)/Utils/aliases-server-fbrowser-v4i.cfg);\
	Macro(FBROWSER_IC_INIT);\
	Include($(CfgDir)/Utils/aliases-server-video-player.cfg);\
	Make(var,app_name,by_value,VLC);\
	Make(var,open_file,by_value,);\
	Make(var,vlc_dbus,by_value,qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2);\
	Make(var,do_app_init,by_value,1);\
	Make(var,vlc_dbus_layout,\
	     V=`$(CfgDir)/Utils/registry.sh $(TmpDir) get vlc_dbus_layout`;\
	     if [ "x$V" = "x" ]; then echo "3x4"; else echo $V; fi);\
	Make(var,app_manage_mode,by_value,vlc_dbus_$(vlc_dbus_layout));

(Exit)=\
	Macro(FBROWSER_IC_EXIT);\
	Exec($(CfgDir)/Utils/registry.sh $(TmpDir) set vlc_dbus_layout $(vlc_dbus_layout));

(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_general

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 "$(fbrowser_dir)"; 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;sleep 1;V=`pgrep vlc`;if [ "x$V" != "x" ]; then pkill vlc; fi);

APP_FULLSCREEN=\
	Emulate(key,f);

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)

Open DVD=\
	Macro(APP_QUIT);\
	Exec(vlc --control dbus dvdsimple://);

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

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

Layout 3x4=\
	Make(mode,vlc_dbus_3x4);

Layout 5x1=\
	Make(mode,vlc_dbus_5x1);

[ModeEnd]

[Mode]=vlc_dbus_3x4 : vlc_dbus_general, default_video_player

APP_POST_SETUP=\
	Make(var,vlc_dbus_layout,by_value,3x4);\
	Make(var,app_manage_mode,by_value,vlc_dbus_$(vlc_dbus_layout));

APP_MENU=\
	Set(menu,replace,Open DVD,Alt-F4,Layout 5x1,PowerMgmt);\
	Macro(ALLIN1MENU);\
	Macro(MEDIACENTER_MENU);

% PowerMgmt by Utils/aliases-server.cfg

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

[Mode]=vlc_dbus_5x1 : vlc_dbus_general,default_video_player_5x1 

APP_POST_SETUP=\
	Make(var,vlc_dbus_layout,by_value,5x1);\
	Make(var,app_manage_mode,by_value,vlc_dbus_$(vlc_dbus_layout));

APP_MENU=\
	Set(menu,replace,Help,Mute,Quit,Fullscreen,Files,Open DVD,Alt-F4,Layout 3x4,IMDB,PowerMgmt);\
	Macro(ALLIN1MENU);\
	Macro(MEDIACENTER_MENU);

Fullscreen=\
	Macro(APP_FULLSCREEN);

[ModeEnd]

[End]
