You may want to use this code and modify it to your needs, please do post you improvements to it here.
//Jan-Erik
/* Install MPlayer */
'@echo off'
call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
call SysLoadFuncs
cfg.snap = 0
cfg.dive = 0
cfg.vman = 0
cfg.t23 = 0
cfg.uniaud = 0
cfg.noshare = 0
cfg.bufsize = 0
env = 'ENVIRONMENT'
cfg.wo = ( pos( '/WO', translate( ARG(1) ) ) > 0 )
if cfg.wo = 0 then
do
cfg.snap = ( pos( '/SNAP', translate( ARG(1) ) ) > 0 )
if cfg.snap = 0 then
cfg.vman = ( pos( '/VMAN', translate( ARG(1) ) ) > 0 )
if cfg.snap = 0 & cfg.vman = 0 then
cfg.t23 = ( pos( '/T23', translate( ARG(1) ) ) > 0 )
if cfg.snap = 0 & cfg.vman = 0 & cfg.t23 = 0 then
cfg.dive = ( pos( '/DIVE', translate( ARG(1) ) ) > 0 )
else cfg.dive = 0
end
cfg.vo = ( pos( '/VO', translate( ARG(1) ) ) > 0 )
cfg.dart = ( pos( '/DART', translate( ARG(1) ) ) > 0 )
if cfg.dart = 0 then
cfg.uniaud = ( pos( '/UNIAUD', translate( ARG(1) ) ) > 0 )
if cfg.dart = 0 & cfg.uniaud = 0 then
cfg.noshare = ( pos( '/NOSHARE', translate( ARG(1) ) ) > 0 )
if cfg.dart = 0 & cfg.uniaud = 0 & cfg.noshare = 0 then
parse value translate( ARG(1) ) with .'/BUFSIZE'buf_size'/'.
if datatype( strip( buf_size ), 'W' ) then
cfg.bufsize = strip( buf_size )
home_path = VALUE( 'HOME',, env )
if length( home_path ) = 0 then
home_path = OSBootDrive()'\Apps'
if pos( '/I', translate( ARG(1) ) ) > 0 then
do
parse value translate( ARG(1) ) with .'/I'programs_path'/'.
programs_path = strip( programs_path )
end
if directory( programs_path ) = '' then
do
programs_path = VALUE( 'PROGRAMS',, env )
if length( programs_path ) = 0 then
programs_path = VALUE( 'MMBASE',, env )
if length( programs_path ) = 0 then
programs_path = OSBootDrive()
end
if stream( programs_path'\MPlayer\mplayer.exe', 'C', 'query exists' ) <> '' then
programs_path = programs_path'\MPlayer' /* Change MPlayer by hand if you use another folder name */
else
do
call SysFileTree programs_path'\*mplayer.exe', 'file', 'SFO'
if file.0 > 0 then
programs_path = strip( filespec( 'd', file.i )||filespec( 'p', file.i ), 't', '\' )
else
do
say "Can't find MPlayer in the programs directory"
drives = SysDriveMap( 'C:', 'USED' )
do i = 1 to words( drives )
call SysFileTree subword( drives, i )||'\*mplayer.exe', 'file', 'SFO'
if file.0 > 0 then
do
programs_path = strip( filespec( 'd', file.i )||filespec( 'p', file.i ), 't', '\' )
leave i
end
end
end
end
if stream( programs_path'\mplayer.exe', 'C', 'query exists' ) = '' then
do
say "Can't find MPlayer on your computer"
return 1
end
'SET MPLAYER_HOME='home_path'\.mplayer'
'SET MPLAYER_CODECS_DIR='programs_path'\Codecs'
'SET MPLAYER_PATH='programs_path'\mplayer.exe'
if ChkCreatePath( programs_path ) = 0 then
say 'Installation Directory for MPlayer is ready'
else do
say "Couldn't create Installation directory"
Exit -1
end
if ChkCreatePath( VALUE( 'MPLAYER_CODECS_DIR',, env ) ) = 0 then
say 'Directory to store MPlayer Codecs is ready'
else say 'Codec directory not available'
mplayer_home = VALUE( 'MPLAYER_HOME',, env )
if ChkCreatePath( mplayer_home ) = 0 then
do
say 'Directory to store MPlayer configuration prepared'
call WriteCfg mplayer_home'\config'
call WriteInput mplayer_home'\input.conf'
say 'Configuration written'
end
else do
say "Couldn't create directory for MPlayer configuration,"
say "will use standard settings instead..."
end
prgm.destpath = programs_path
prgm.name = 'mplayer.exe'
prgm.objid = 'MPPLAYER'
prgm.icon = 'Mplayer.ico'
prgm.wpname = 'MPlayer'
prgm.wpdest = '<MMPM2_FOLDER>'
prgm.params = '"%**P\%**F"'
prgm.assocfilter = '*.mpg,*.avi,*.wmv,*.mov,*.divx,*.flv,*.mpeg,*.vob,*.mp4,*.asf,*.matroska,*.fli,*.m4v,*.rm,*.ram'
rc = CreatePrgmObj()
exit rc
CreatePrgmObj: procedure expose prgm.
setupstring = 'OBJECTID=<'prgm.objid'>;EXENAME='prgm.destpath'\'prgm.name';PROGTYPE=PM;PARAMETERS='prgm.params';ASSOCFILTER='prgm.assocfilter';ICONFILE='prgm.icon';'
/*Create program in folder and attach icon*/
rc = SysCreateObject( 'WPProgram', prgm.wpname, prgm.wpdest, setupstring, 'U' )
if rc then
say prgm.wpname' has been successfully installed'
else
say prgm.wpname' failed installation'
Return rc
WriteCfg: procedure expose cfg.
retval = stream( ARG(1), 'C', 'QUERY EXIST' )
if retval <> '' then '@DEL 'ARG(1)' /F'
if stream( ARG(1), 'C', 'OPEN WRITE' ) = 'READY:' then
do
call lineout ARG(1), '# Settings for stream/file caching'
call lineout ARG(1), 'cache=12288'
call lineout ARG(1), 'cache-min=30'
call lineout ARG(1), ''
call lineout ARG(1), '# Setting for Browser User Agent response'
call lineout ARG(1), 'user-agent=NSPlayer/4.1.0.3856'
if cfg.wo then
do
call lineout ARG(1), ''
call lineout ARG(1), '# Force mPlayer to use WarpOverlay'
call lineout ARG(1), 'vo=kva:wo'
end
else if cfg.snap then
do
call lineout ARG(1), ''
call lineout ARG(1), '# Force mPlayer to use SNAP'
call lineout ARG(1), 'vo=kva:snap'
end
else if cfg.vman then
do
call lineout ARG(1), ''
call lineout ARG(1), '# Force mPlayer to use VMAN'
call lineout ARG(1), 'vo=kva:vman'
end
else if cfg.dive then
do
call lineout ARG(1), ''
call lineout ARG(1), '# Force mPlayer to use DIVE'
call lineout ARG(1), 'vo=kva:dive'
end
if cfg.dart then
do
call lineout ARG(1), ''
call lineout ARG(1), '# Force mPlayer to use DART'
call lineout ARG(1), 'ao=kai:dart'
end
else if cfg.uniaud then
do
call lineout ARG(1), ''
call lineout ARG(1), '# Force mPlayer to use UniAUD'
call lineout ARG(1), 'ao=kai:uniaud'
end
else if cfg.noshare then
do
call lineout ARG(1), ''
call lineout ARG(1), '# Force mPlayer to use DART No Share'
call lineout ARG(1), 'ao=kai:noshare'
end
if cfg.bufsize then
do
call lineout ARG(1), ''
call lineout ARG(1), '# Force mPlayer to use buffer size'
call lineout ARG(1), 'ao=kai:bufsize'||cfg.bufsize
end
if cfg.vo then
do
call lineout ARG(1), ''
call lineout ARG(1), '# Video Overlay Options and VIO Message Window Options'
call lineout ARG(1), 'really-quiet=yes'
call lineout ARG(1), 'fixed-vo=yes'
call lineout ARG(1), 'colorkey=0x000001'
end
call stream ARG(1), 'C', 'CLOSE'
end
Return 0
WriteInput: procedure expose cfg.
retval = stream( ARG(1), 'C', 'QUERY EXIST' )
if retval <> '' then '@DEL 'ARG(1)' /F'
if stream( ARG(1), 'C', 'OPEN WRITE' ) = 'READY:' then
do
call lineout ARG(1), '# Settings for User Control of mPlayer playback'
call lineout ARG(1), 'MOUSE_BTN2 vo_fullscreen'
call lineout ARG(1), 'PGUP pt_step -1'
call lineout ARG(1), 'PGDWN pt_step 1'
call lineout ARG(1), '+ volume 5'
call lineout ARG(1), '- volume -5'
call stream ARG(1), 'C', 'CLOSE'
end
Return 0
OSBootDrive: procedure
BootDrive = substr( value( 'RUNWORKPLACE' ,, 'ENVIRONMENT' ), 1, 2 )
if BootDrive = '' then
BootDrive = substr( value( 'COMSPEC' ,, 'ENVIRONMENT' ), 1, 2 )
if length( BootDrive ) = 0 then
BootDrive = 'C:'
Return BootDrive
ChkCreatePath: procedure
rc = ( directory( ARG(1) ) = '' )
if rc = 1 then
call ChkCreatePath strip( filespec( 'D', ARG(1) )||filespec( 'P', ARG(1) ), 'T', '\' )
if rc = 1 then
'@mkdir 'ARG(1)
Return rc