OS/2, eCS & ArcaOS - Technical > Programming
mPlayer install script & add dereg of old avi codecs ???
Greggory Shaw:
--- Quote from: Martin Iturbide on August 07, 2013, 09:14:10 pm ---Hi Greggory
I will also like to invite you to write some lines about MPlayer and OS/2 on the OS2World.com/wiki
It uses the same userid/password of this forum.
Regards
Martin
--- End quote ---
Sure after I add the code for MP3s codec and figure how to get rid of the old codecs !
Greggory
Jan-Erik Lärka:
You may want to use this code and modify it to your needs, please do post you improvements to it here.
//Jan-Erik
--- Code: ---/* 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
--- End code ---
Greggory Shaw:
Exactly what I was looking for ! Thank you Jan-Erik !
I'm adding the options to install MP3 codec and dereg the old MMAVI classes.
Could you please post some examples of the install parameters for your script.
Greggory
Jan-Erik Lärka:
Hello,
You should specify the installation options as parameters to take advantage of the drivers that give the best experience/performance with your hardware. It would however be nice if you can come up with code how to automatically detect installed drivers and which one should take precedence.
//Jan-Erik
InstMPlayer <parameters>
VideoName/WOWarp Overlay/SNAPSNAP/VMANVMan/T23T23 Laptop/DIVEDIrect Video Extension/VOVideo Overlay OptionsAudioName/DARTDigital Audio Real Time/UNIAUDUNIversal AUDio/NOSHAREDon't share audio/BUFSIZE 1234Use buffer size of 1234/I D:\MyPrograms Tell the script where MPlayer has been unpacked
Note: The code expect MPLayer to be placed in a folder named "MPlayer" and if you specify the path it will install faster if you specify /I D:\MyPrograms instead of /I D:\MyPrograms\MPlayer.
Programs path search order query the environment variables for, PROGRAMS and MMBASE, but the code will fall back to search for MPLayer on the boot drive if MPlayer cant be found there.
It will search though every drive if that also fail, until it find mplayer.exe
Silvan Scherrer:
btw you don't have to specify any options to vo=kva or ao=kai, as those libs automaticaly search your system and uses the best combination.
vo search order is: WO, SNAP, DIVE
ao search order is: UNIAUD, DART
regards
Silvan
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version