home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Warp Uncensored
/
OS2_WARP_UNCENSORED.ISO
/
rexx
/
vidbounc.cmd
< prev
Wrap
OS/2 REXX Batch file
|
1995-04-02
|
13KB
|
282 lines
/******************************************************************************/
/* VIDBOUNC.CMD - Open an SMV movie (default to the shipped MACAW.AVI file), */
/* and play it, alternating the position and size of the default video */
/* playback window on the screen. */
/* */
/* This command file demonstrates the following concepts: */
/* */
/* + Use of the mciRxSendMCICommand and mciRxGetErrorString REXX MM */
/* extensions. */
/* + Use of digital video Media Control Interface (MCI) string commands, */
/* including those which: */
/* */
/* * query information about the file */
/* * move the default video window around the screen */
/* * change the size of the video window */
/* * control the playback of the SMV movie */
/* */
/* NOTE: Due to the requirements of displaying digital video, this command */
/* file MUST be invoked via the command: */
/* */
/* PMREXX VIDBOUNC arguments */
/* */
/* If you invoke VIDBOUNC directly from an OS/2 command line, you will receive*/
/* an error code/message similar to the following: */
/* */
/* 5041 = Not currently in a Presentation Manager Session. */
/* */
/******************************************************************************/
signal on halt /* Handle case where the user hits Ctrl+Break */
/* to end the program */
arg filename 'V='volume /* Get the command line arguments */
/* filename = The video file to use for */
/* playback */
/* 'V=nn' = (optional) Set the volume to */
/* nn percent */
/* Provide help text, if desired */
if filename = '?' then
do
signal Help
end
/* Initialize various variables */
alias = 'YIPPEE' /* String used in each MCI command string */
defvol = 75 /* Default volume level */
deffn = 'MMOS2\MOVIES\MACAW.AVI' /* Default SMV file name */
screenx = 1024 /* Assumed display horizontal resolution */
screeny = 768 /* Assumed display vertical resolution */
/* If no filename was supplied, find the correct drive containing our default */
/* file (assume it exists). This also affords us the chance of ensuring that */
/* OS/2 Multimedia is installed. */
if filename = '' then
do
/* The MMBASE environment variable will exist if OS/2 Multimedia has been */
/* installed. It contains the desired drive letter. */
mmbase = value('MMBASE',,'OS2ENVIRONMENT')
if mmbase = '' then
do
say 'WHOA! OS/2 Multimedia support seems to be missing from this system.'
say 'Ensure ''MMPM/2'' is installed and the MMBASE environment variable'
say 'is set to point to d:\MMOS2 (where d: is the appropriate drive).'
exit 1
end
else
do
/* MMBASE exists, assume the first letter is the drive letter. */
/* Assemble the default filename */
filename = left(mmbase,1)':'deffn
end
end
/* If no volume was specified, ensure the default value is set, to keep from */
/* blowing people out of their chairs...! */
if volume = '' then volume = defvol
/* Have the user verify the resolution of the screen */
say
say 'Assuming a screen resolution of' screenx 'by' screeny'...'
say 'If this is OK, press Enter. Otherwise, enter your screen''s resolution'
say 'in the form x y , where x is the width and y is the height.'
pull x y
if x <> '' then
do
screenx = x
screeny = y
end
/* Initialize the OS/2 Multimedia REXX support */
call RxFuncAdd 'mciRxInit', 'MCIAPI', 'mciRxInit'
call mciRxInit
/* Open the SMV file, using the default device. Specify an 'alias' to use */
/* on subsequent MCI commands. Do not specify the SHAREABLE keyword, because */
/* we want exclusive access to all necessary devices, since there is no way */
/* for this session to acquire its multimedia resources, should another */
/* application wrest control away from us. */
/* */
/* SendMCICommand is a local procedure which calls mciRxSendString... */
say 'Opening' filename'...'
cmdRC = SendMCICommand('OPEN' strip(filename) 'ALIAS' alias 'WAIT')
if cmdRC <> 0 then
signal CleanupAndExit
else
do
/* Set the volume */
if SendMCICommand('SET' alias 'AUDIO VOLUME' volume 'WAIT') = 0 then
say 'Volume set to' volume'%.'
/* Set the time format to something video-ish, for upcoming STATUS commands*/
if SendMCICommand('SET' alias 'TIME FORMAT HMSF WAIT') = 0 then
say 'Time format set to Hours:Minutes:Seconds:Frames.'
/* Get some information about the video file and display it. */
/* NOTE: SendMCICommand sets the mciResults variable if there is any */
/* return information... */
say 'Video information:'
if SendMCICommand('STATUS' alias 'LENGTH WAIT') = 0 then
say ' Length =' mciResults
if SendMCICommand('STATUS' alias 'HORIZONTAL VIDEO EXTENT WAIT') = 0 then
vidx = mciResults
else vidx = 0
if SendMCICommand('STATUS' alias 'VERTICAL VIDEO EXTENT WAIT') = 0 then
vidy = mciResults
else vidy = 0
if vidx <> 0 & vidy <> 0 then
say ' Width and height: 'vidx 'and' vidy', respectively.'
if SendMCICommand('STATUS' alias 'NORMAL RATE WAIT') = 0 then
say ' Frame rate: 'mciResults 'frames/second.'
/* Now, play the video in each corner of the display at regular speed, */
/* normal size, then play in the middle of the screen at regular speed, */
/* normal size. Finally, double the size of the video, center it in the */
/* screen, and play it at a 'fast' speed. */
/* */
/* To move the default window, use the PUT command: */
/* */
/* PUT object WINDOW x y width height MOVE WAIT */
/* */
/* width and height can be 0's when doing a MOVE operation. */
/* */
/* The FROM 0 keywords in the PLAY command mean to always start playback */
/* from the beginning of the file. This helps us avoid sending a SEEK */
/* command before each PLAY. */
say 'Now playing the movie:'
say ' Bottom left...'
if SendMCICommand('PUT' alias 'WINDOW AT 0 0 0 0 MOVE WAIT') = 0 then
call SendMCICommand 'PLAY' alias 'WAIT'
/* Calculate right-hand X value and top-most Y value. Since the video */
/* extents we queried were just for the size of the video, include a fudge */
/* factor to account for the borders of the default video window */
/* We can figure out the fudge factor fairly finely 8-) by utilizing the */
/* WHERE command, which will give us the complete position/size of the */
/* default playback window. */
if SendMCICommand('WHERE' alias 'WINDOW WAIT') = 0 then
do
parse value mciResults with winx winy winx2 winy2
fudgex = winx2 - winx - vidx
fudgey = winy2 - winy - vidy
end
x = screenx - vidx - fudgex /* Starting point for right top/bottom videos */
y = screeny - vidy - fudgey /* Starting point for top left/right videos */
say ' Bottom right...'
if SendMCICommand('PUT' alias 'WINDOW AT' x '0 0 0 MOVE WAIT') = 0 then
call SendMCICommand 'PLAY' alias 'FROM 0 WAIT'
say ' Top left...'
if SendMCICommand('PUT' alias 'WINDOW AT 0' y '0 0 MOVE WAIT') = 0 then
call SendMCICommand 'PLAY' alias 'FROM 0 WAIT'
say ' Top right...'
if SendMCICommand('PUT' alias 'WINDOW AT' x y '0 0 MOVE WAIT') = 0 then
call SendMCICommand 'PLAY' alias 'FROM 0 WAIT'
say ' Centered...'
if SendMCICommand('PUT' alias 'WINDOW AT' x/2 y/2 '0 0 MOVE WAIT') = 0 then
call SendMCICommand 'PLAY' alias 'FROM 0 WAIT'
say ' Centered, "pel-doubled", playing fast (no sound)...'
x = (screenx-(vidx*2)-fudgex)/2 /* Starting x = width doubled, centered */
x2= x + vidx*2 + fudgex /* Ending x = Starting x + double-width */
/* + borders */
y = (screeny-(vidy*2)-fudgey)/2 /* Starting y = height doubled, centered */
y2= y + vidy*2 + fudgey /* Ending y = Starting y + double-width */
/* + borders */
if SendMCICommand('PUT' alias 'WINDOW AT ' x y x2 y2 'MOVE SIZE WAIT') = 0 then
call SendMCICommand 'PLAY' alias 'FROM 0 FAST WAIT'
say 'Playback complete...Press Enter to continue'
pull
end /* If file loaded OK */
/* Close the instance. */
call SendMCICommand 'CLOSE' alias 'WAIT'
/* Do some REXX cleanup */
call mciRxExit
exit 0
/*******************************/
/***** Various subroutines *****/
/*******************************/
/* Call the REXX function which sends MCI string commands to OS/2 Multimedia. */
SendMCICommand:
arg command
/* Last two parameters are reserved, must be set to 0 */
rc = mciRxSendString(command, 'mciResults', '0', '0')
if rc <> 0 then
do
/* Sometimes the error return code has the 'device ID' in the high */
/* order word, so mask off that word before querying the error string */
if rc > 65536 then rc = X2D(right(D2X(rc),4))
call mciRxGetErrorString rc, 'ErrorString'
say 'WHOA! An error occurred while sending an MCI command string.'
say ' Command was "'command'"'
say ' Return code was' rc
/* Error strings only work for MCI errors */
if rc >= 5000 then
say ' System reports "'ErrorString'"'
end
return rc
/* Display help text */
Help:
say
say 'VIDBOUNC [filename] [V=nn]'
say
say 'Display an SMV file and play back in different spots and in different'
say 'sizes on the screen.'
say
say 'Command line arguments (both optional):'
say
say 'filename = Name of the SMV movie file to use.'
say 'V=nn = Set playback volume to nn%.'
exit
/* Common cleanup routine */
CleanupAndExit:
call mciRxExit /* Clean up the MCI Rexx subfunctions */
exit 9 /* Return a non-zero code to .CMD caller */
/* Handle something like a control break */
halt:
say 'Halting...'
call SendMCICommand 'CLOSE' alias 'WAIT'
exit 0