Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for cdplayer.cmd

(view source code of cdplayer.cmd as plain text)

  1. /* CD Player, Version 1.01                                     */
  2. /* Original version:  May  24, 1998                            */
  3. /* Latest update:     June 26, 1999                            */
  4. /* Start OS/2 Audio CD player, ejecting CD-ROM if in the drive */
  5. /* Written by Rob van der Woude                                */
  6. /* Needs OS/2 Multimedia Rexx Support and RexxLib installed    */
  7.  
  8. /* Specify CD Audio drive letter here */
  9. CD_drive = "H:"
  10.  
  11. /* Adjust the delay between eject command */
  12. /* and Audio CD start if necessary        */
  13. delay = 5
  14.  
  15. /* Initialize Multimedia REXX support */
  16. call RxFuncAdd "mciRxInit", "MCIAPI", "mciRxInit"
  17. call mciRxInit
  18.  
  19. /* Initialize RexxUtil */
  20. if RxFuncQuery( "SysLoadFuncs" ) <> 0 then do
  21. 	call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
  22. 	call SysLoadFuncs
  23. end
  24.  
  25. /* Initialize RexxLib */
  26. if RxFuncQuery( "RexxLibRegister" ) <> 0 then do
  27. 	call RxFuncAdd "RexxLibRegister", "RexxLib", "RexxLibRegister"
  28. 	call RexxLibRegister
  29. end
  30.  
  31. /* Display version information */
  32. say
  33. say " CD Player, Version 1.01"
  34. say " Written by Rob van der Woude"
  35.  
  36. /* Eject CD-ROM if in the drive */
  37. if SysDriveInfo( CD_drive ) <> "" then do
  38. 	call Eject
  39. 	call SysSleep delay
  40. end
  41.  
  42. /* Start OS/2's audio CD player */
  43. call SysOpenObject "<MMPM2_MMCDDEVICE01>", 0, 1
  44.  
  45. /* Wait until OS/2's audio CD player is no longer active */
  46. do forever
  47. 	call DosSwitchList "title."
  48. 	active = 0
  49. 	do i = 1 to title.0
  50. 		uctitle = translate( title.i )
  51. 		if pos( "COMPACT DIS", uctitle ) > 0 then active = 1
  52. 	end
  53. 	if active = 0 then leave
  54. 	call SysSleep 5
  55. end
  56.  
  57. /* Eject CD if still in the drive */
  58. if SysDriveInfo( CD_drive ) = "" then call Eject
  59.  
  60. /* End of main program */
  61. EXIT
  62.  
  63.  
  64.  
  65. Eject: procedure
  66. 	/* Open the CD-Audio device and send the Sesame Open command */
  67. 	rc = mciRxSendString( "open CDAudio01 alias CDA wait", "RetStr", "0", "0" )
  68. 	rc = mciRxSendString( "stop CDA wait", "RetStr", "0", "0" )
  69. 	rc = mciRxSendString( "set CDA door open wait", "RetStr", "0", "0" )
  70. 	rc = mciRxSendString( "close CDA wait", "RetStr", "0", "0" )
  71. return
  72.  

page last modified: 2024-04-16; loaded in 0.0059 seconds