OS/2, eCS & ArcaOS - Technical > Programming
mPlayer install script & add dereg of old avi codecs ???
Jan-Erik Lärka:
Hello,
I'm sure I'm not the only one that would like to see it!
Post or send it any way you like. A link here would be nice as well.
Greggory Shaw:
--- Quote from: Jan-Erik Lärka on December 07, 2013, 11:38:24 am ---Hello,
I'm sure I'm not the only one that would like to see it!
Post or send it any way you like. A link here would be nice as well.
--- End quote ---
NOTE: I just realized i posted the wrong version that doesn't have the advance install but that does not affect anything.
You must create a program object for this CMD file /w parameters %*%**N for drag & drop to work as intended (This is not the whole package).
- now any mPlayer zip file dropped on the program obj is automatically installed in the x:\programs\mplayer directory.
- advanced install allow you to choose where
- a backup is made of the original install if present.
- allows you to de-register the old worthless MMAVI class so mplayer becomes the default player.
- allows you to add the MP3 codec to your system.
Here is the first half, the forum wouldn't let post the entire listing. Keep in mind that that I have little experience in Rexx and the main work is from Jan-Erik.
Thanks
Greggory
--- Code: ---/*. */
call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
call SysLoadFuncs
SIGNAL ON SYNTAX
SIGNAL ON HALT
Parse arg String var1 var2
Date = '12.06.2013'
Version='004'
FileName = var1
Location = String
cfg.snap = 0
cfg.dive = 0
cfg.vman = 0
cfg.t23 = 0
cfg.uniaud = 0
cfg.noshare = 0
cfg.bufsize = 0
Currentdir = Directory()
ProgramsDir = VALUE('PROGRAMS',,'OS2ENVIRONMENT')
/***********************************************************************
* ATTENTION - For the DEFAULT option: *
* *
* In some cases this script may not find the right default path! *
* *
* mPlayerDir = x:\Programs\mPlayer *
* *
***********************************************************************/
mPlayerDir = ProgramsDir || '\MPLAYER'
BootDrive = GetOS2BootDrive()
CALL ColorPage
CALL Banner
theSelect=getSelection()
SELECT
WHEN theSelect=1 THEN DO
SAY ""
call InstallmPlayer
Exit 0;
END
WHEN theSelect=2 THEN DO
SAY ""
call Dereg
Exit 0;
END
WHEN theSelect=3 THEN DO
SAY ""
call AddCodecMP3
Exit 0;
END
WHEN theSelect=4 THEN DO
SAY ""
call mPlayerAdv
END
OTHERWISE
NOP
END
Exit 0;
getSelection: PROCEDURE
QUIT=0
SAY "Select option:"
SAY ""
SAY " 1: Install mPlayer to Boot Partition"
SAY ""
SAY " 2: De-register MMAVI multmedia class"
SAY " 3: Add the MP3 codec to the system."
SAY ""
SAY " ('h' for help)"
SAY " ('q' for exit)"
SAY ""
Do UNTIL QUIT=1
say '>'
parse value SysCurPos() with aktzeile aktspalte
newposition=SysCurPos(aktzeile-1,2)
pull theChar
IF theChar='H' then call mPlayerHelp
IF theChar='Q' then EXIT 1
if LENGTH(theChar)==1 & VERIFY(theChar, "1234")==0 THEN QUIT=1
ELSE
call beep 100, 100
call SysCurPos aktzeile-1, 0
SAY "1B"x || "[K"
call SysCurPos aktzeile-1, 0
END
SAY ""
RETURN theChar
/***********************************************************************
Install or Update Os2/eCS default mPlayer installations
***********************************************************************/
InstallmPlayer:
NewVer = FileName
parse var NewVer FileName "-" .
CALL mBanner
IF stream( programs_path'\MPlayer\mplayer.exe', 'C', 'query exists' ) <> ''
THEN
DO
CALL BackupMplayer
CALL DeleteMplayer
END
address cmd 'unzip -o ' || Location || ' -d ' || mPlayerDir;
RunDir = CurrentDir
Dir = mPlayerDir || '\' || Filename ;
CALL mPlayerConfig
say ''
say color.green || 'Updated the default ' || FileName || ' installation on your desktop...' || color.gray;
pause
RETURN
mPlayerAdv:
NewVer = FileName
parse var NewVer FileName "-" .
CALL AdvInstBanner
CALL DeleteMplayer
address cmd 'unzip -o ' || String || ' -d ' || mPlayerDir ;
RETURN
/***********************************************************************/
/***********************************************************************/
BackupMplayer:
CALL DeleteBackup
Copy_Cmd = mPlayerDir || ' ' || mPlayerDir || '-BAK\ /S /E'
XCOPY Copy_Cmd
CALL SysPutEA mPlayerDir || '-BAK', '.LONGNAME', ''
RETURN
DeleteBackup:
fDir = ProgramsDir || '\' || FileName || '-BAK'
/* We only care about the fully qualified path names and in subfolders as well,
* so use "O" option to drop dates, times, attribs, etc.
*/
rtc = SysFileTree( STRIP( fDir, 'T', '\' )||"\*", "filelist", "SFO" )
/* Create worker loops */
Do A = 1 to filelist.0 /* Loop through file list using count in stem base */
rtc = SysFileDelete( filelist.A ) /* delete file */
End
RETURN
DeleteMplayer:
fDir = mPlayerDir
/* Create Match list of do-not-deletes, upper case! */
NoDel.1='MPLAYER.EXE'
NoDel.2='MENCODER.EXE'
NoDel.3='CODECS'
NoDel.0=3 /* Set stem array length */
/* List files and delete each of them */
/* Read directory and all sub-directories and create file list in stem array filelist,
* take care of possible trailing back slash.
*/
/* We only care about the fully qualified path names and in subfolders as well,
* so use "O" option to drop dates, times, attribs, etc.
*/
rtc = SysFileTree( STRIP( fDir, 'T', '\' )||"\*", "filelist", "SFO" )
/* Create worker loops */
Do A = 1 to filelist.0 /* Loop through file list using count in stem base */
Do B = 1 to NoDel.0 /* Compare to each value in NoDel array */
If Pos( NoDel.B, Translate( filelist.A ) ) > 0 Then /* found a match - using upper case to ensure proper matching */
Iterate A /* Jump to the next file in the list and don't process this one! */
End
rtc = SysFileDelete( filelist.A ) /* delete file */
/* Add programming code here to check error codes if wanted - for instance cant delete because locked file */
/* If rtc = 0 Then Say FileSpec( filelist.A, 'N' ) 'deleted' */
End
PAUSE
RETURN
/***********************************************************************/
/***********************************************************************/
ColorPage:
/***********************************************************************
Set some colors, thanx to Dmitry A.Steklenev for the inspiration *
enable ANSI extended screen and keyboard control *
*/
'@ansi on > nul'
color.brown = "1B"x"[0;33m"
color.red = "1B"x"[1;31m"
color.green = "1B"x"[1;32m"
color.yellow = "1B"x"[1;33m"
color.blue = "1B"x"[1;34m"
color.magenta = "1B"x"[1;35m"
color.cyan = "1B"x"[1;36m"
color.white = "1B"x"[1;37m"
color.gray = "1B"x"[0m"
RETURN
Banner:
/***********************************************************************
Startup Message *
*/
say color.gray || 'Thank you for using '|| color.magenta || 'mPlayerDD' ||,
color.gray || ', an automated tool for Os2/eCs.'
say color.cyan || 'Version ' || Version || color.gray || ' -- ' || Date
say ''
say color.gray || 'This Program is released under the Gnu Public Licence',
|| '(GPL).'
say 'See the file COPYING for further information.'
say color.gray || 'Copyright (c) 2011 by '|| color.white ||,
'Greggory Shaw'
say ''
say color.gray || 'Default option will install or upgrade the default ' || color.green || 'mPlayer' || color.gray || ' installation'
say '(as defined by SET PROGRAMS=' || color.green || mPlayerDir || color.gray || ') on your eCS system.'
say ''
say 'Use the advance option to specify the install locations.'
say ''
RETURN
mBanner:
/***********************************************************************
Default Option Message *
*/
cls
say ''
say color.green || 'Default Option:' || color.gray
say ''
say color.gray || 'This option automatically installs' color.green || FileName || color.gray || ' to the'
say "default location " || color.green || mPlayerDir || color.gray ||' set by eCS.'
say ''
say 'A backup of the original will be create in ' || color.green || mPlayerDir || '-BAK' || color.gray
say ''
say 'Is this the correct default path ?'
say ''
say color.green || ProgramsDir || '\' || FileName || color.gray
key = SysGetKey()
parse upper var key key
if key <> 'Y' then call DontInstall
RETURN
AdvInstBanner:
/***********************************************************************
Advanced Option Message *
*/
cls
say ''
say color.green || 'Advanced Option:' || color.gray
say ''
say 'Please enter the installation directory for ' || FileName || '.'
say ''
say 'If installing to root do not use the backslash (\),'
say 'use this format (E:)'
say ''
say '----------------------------------------------------'
PARSE PULL mPlayerDir
cls
say ''
say 'Is this the correct path ?'
say ''
say color.green ||mPlayerDir || color.gray
say ''
say 'y/n?'
say ''
key = SysGetKey()
parse upper var key key
if key <> 'Y' then call DontInstall
say ''
say ''
say 'If you are installing to a existing ' || FileName || ' directory'
say 'would you like to create a backup of your current installation?'
say ''
say color.green ||mPlayerDir || color.gray
fDir = mPlayerDir || '\' || FileName || '-BAK'
key = SysGetKey('NOECHO')
parse upper var key key
if key == 'Y' then call BackupMplayer
RETURN
mHelp:
/***********************************************************************
Help Message *
*/
CLS
say ''
SAY color.green || 'Default install option:' || color.gray
say ''
say ''
pause
CLS
say ''
say color.green || 'Advanced install option:' || color.gray
say ''
say ''
pause
CLS
say ''
say ''
pause
CLS
RETURN
/***********************************************************************/
/***********************************************************************/
mPlayerConfig:
/***********************************************************************
Install mPlayer to the x:\PROGRAMS directory *
*/
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 = 'Video.ico'
prgm.wpname = 'MPlayer'
prgm.wpdest = ''
prgm.params = '"%**P\%**F"'
prgm.assocfilter = '*.mpg,*.avi,*.wmv,*.mov,*.divx,*.flv,*.mpeg,*.vob,*.mp4,*.asf,*.mkv,*.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), '# Write your default config options here!'
call lineout ARG(1), 'ao=kai:dart'
call lineout ARG(1), ''
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 of part one */
--- End code ---
Greggory Shaw:
Here's the second half.
--- Code: ---
Dereg:
/***********************************************************************
De-register MMAVI classes *
*/
cls
say 'Option - De-register the MMAVI class'
say ''
say ''
say color.red ||'*** Warning *** -- You are about to de-register a WPS class.' || color.gray
say ''
say 'The MMAVI class is very old and out of date. I have never had problems'
say 'deleting MMAVI, however be sure to have a backup before proceeding.'
say ''
say 'This will allow mPlayer to become the first play option for AVI files.'
say ''
say 'Y/n?'
say ''
key = SysGetKey()
parse upper var key key
if key <> 'Y' then call DontInstall
Call SysDeregisterObjectClass("MMAVI")
Return
AddCodecMP3:
/***********************************************************************
Register MP3 codecs *
*/
cls
say 'Option - Add the MP3 codec to Os2/eCs'
say ''
say 'Y/n?'
say ''
key = SysGetKey()
parse upper var key key
if key <> 'Y' then call DontInstall
progPath = CurrentDir
progName = "install_MP3.cmd"
/* code sequence to call another CMD file from within an CMD file */
cmdLine = progPath || '\' || progName
"cmd /c " cmdLine
/* "RC" contains the return code */
if rc <> 0 & rc <> "RC" then
say "Error: The program ends with RC = " || rc
pause;
RETURN
/***********************************************************************
Query the bootdrive *
*/
GetOS2BootDrive: PROCEDURE expose (exposeList)
/* install a local error handler */
signal on Syntax name GetOS2BootDrive1
boot_drive = ''
boot_drive = SysBootDrive()
GetOS2BootDrive1:
/* if SysBootDrive() failed, boot_drive is still */
/* empty */
/* SysBootDrive() is only in the newer versions */
/* of REXXUTIL! */
if boot_drive = '' then
do
/* You should do further tests to ensure that */
/* the result of this method is correct! */
parse upper value VALUE( "PATH",, prog.__env ) with "\OS2\SYSTEM" -2,
boot_drive +2
end /* if boot_drive = '' then */
return boot_drive
DontInstall:
say ''
say ''
say color.red || 'Installation was canceled.' || color.gray;
pause;
EXIT 0;
SYNTAX:
SAY 'SYNTAX ERROR:' errortext( rc ) 'in:'
SAY sourceline( sigl )
'pause'
EXIT
RETURN
HALT:
SAY 'HALT occurred in:'
SAY sourceline( sigl )
'pause'
EXIT
RETURN
--- End code ---
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 ---
I'm going to be offline for about a week, but I'll write something up during that time. I just finished an install script for mplayer, mp3 codec and remove the old MMAVI codecs !
Greggory
Greggory Shaw:
Upadated Media Pack & Drag & Drop Install script for Mplayer/2 !
Updated to v.008 - http://www.os2notes.com/os2mplayer.html
Need help improving this please !
Media Pack started as a Rexx install script for mPlayer, now it has the ablity to install mPlayer/2 by Drag & Drop. The ability to install the MP3 codec and remove the old MMAVI class has also been added to the script.
With the MMAVI class gone Mplayer becomes the default player for AVI files, no more right clicks just to play. :D
Cheers
Greggory
Navigation
[0] Message Index
[*] Previous page
Go to full version