home *** CD-ROM | disk | FTP | other *** search
/ Network PC / Network PC.iso / amiga utilities / disk utilities / dirutil / dopus / opus5utils / arexx / playmod_mp.dopus5 < prev    next >
Encoding:
Text File  |  1997-11-21  |  4.9 KB  |  143 lines

  1. /* Mod-Player for Directory Opus 5.
  2.    By Leo Davidson ("Nudel", P0T-NOoDLE/Gods'Gift Utilities)
  3.  
  4. $VER: PlayMod_MP.dopus5 1.2 (18.8.95)
  5.  
  6.    This version is for use with MultiPlayer by Bryan Ford, but should be
  7.    easy to adapt to any other player with an ARexx port, such as
  8.    Eagle/DeliTracker, DMP, etc.
  9.    (In fact, a DeliTracker version should come with this script!).
  10.  
  11.    If you include the path of a module on the command line, using {f}, only
  12.    this mod will be played. If you omit the {f}, the program will play each
  13.    selected file in the first SOURCE lister, giving you a requester to go to
  14.    the next file or stop playing.
  15.  
  16.    If the player's ARexx port is not found, the program will be run for
  17.    you (you should edit the path below). This means the script may fail if
  18.    you disable the player's ARexx port, or give an incorrect command line
  19.    to it.
  20.    If the player's ARexx port takes over a minute to appear, an error
  21.    requester will appear on the DOpus screen and the script will quit.
  22.    REMEMBER to add the "RUN" command to the player command line if it does
  23.    not automatically detach from the shell (MultiPlayer does)!
  24.  
  25.    If the player was running to start with, or the user selects
  26.    "Leave Playing", the module will continue playing when the script finishes.
  27.    Otherwise, the player will be quit.
  28.  
  29. Call as:
  30. ------------------------------------------------------------------------------
  31. ARexx    DOpus5:ARexx/PlayMod_MP.dopus5 {Qp} [{f}]
  32. ------------------------------------------------------------------------------
  33. Turn off all switches.
  34.  
  35.    v1.00 -> v1.01 - Now uses stem variables to get the lister handle.
  36.                     Some minor tidying up.
  37.                     Now checks to make sure the DOPUS.x port exists.
  38.     v1.01 -> v1.2 - Now uses Show() instead of ShowList(). (Thanks Stoebi)
  39.                     Style Guide compliant version numbering and $VER string.
  40.  
  41. */
  42. /*- Path to MultiPlayer command --------------------------------------------*/
  43. MultiPlayer = "DH0:Tools/Music/MultiPlayer"
  44. /*--------------------------------------------------------------------------*/
  45. options results
  46. options failat 99
  47. signal on syntax;signal on ioerr        /* Error trapping */
  48. parse arg DOpusPort FilePath
  49. DOpusPort = Strip(DOpusPort,"B",'" ')
  50. FilePath = Strip(FilePath,"B",'" ')
  51.  
  52. If DOpusPort="" THEN Do
  53.     Say "Not correctly called from Directory Opus 5!"
  54.     Say "Load this ARexx script into an editor for more info."
  55.     EXIT
  56.     END
  57. If ~Show("P",DOpusPort) Then Do
  58.     Say DOpusPort "is not a valid port."
  59.     EXIT
  60.     End
  61. Address value DOpusPort
  62.  
  63. Quit_After = "NO"
  64. If ~Show("P","RXTRACKER") Then Do
  65.     Address Command MultiPlayer
  66.     Quit_After = "YES"
  67.     TickTick = Time(M)
  68.     Do While ~Show("P","RXTRACKER")
  69.         IF Time(M) - TickTick > 0 Then Do
  70.             dopus request '"Error loading MultiPlayer!'||X2C(0A)||'Check its command-line in the ARexx script itself." OK'
  71.             EXIT
  72.             END
  73.         END
  74.     END
  75.  
  76. /* If file-path was specified on command line, just play that mod, else
  77.    go through all the selected ones. */
  78.  
  79. If FilePath = "" Then Do
  80.     lister query source stem source_handle.
  81.     IF source_handle.count = 0 | source_handle.count = "SOURCE_HANDLE.COUNT" Then Do
  82.         dopus request '"You must have a SOURCE lister!" OK'
  83.         EXIT
  84.         End
  85.     lister set source_handle.0 busy 1
  86.  
  87.     lister query source_handle.0 numselentries    /* Get info about selected */
  88.     Lister_NumSelEnt = RESULT            /* entries & path to them */
  89.     lister query source_handle.0 path
  90.     Lister_Path = Strip(RESULT,"B",'"')
  91.  
  92.     Do i=1 to Lister_NumSelEnt
  93.         lister query source_handle.0 firstsel
  94.         Temp_Name = Strip(RESULT,"B",'"')
  95.         lister select source_handle.0 Temp_Name 0
  96.         Temp_Path = Lister_Path || Temp_Name
  97.         Address RXTRACKER Load Temp_Path;Address RXTRACKER Play
  98.  
  99.         If Lister_NumSelEnt - i > 0 Then Do
  100.             If Quit_After = "YES" Then
  101.                 dopus request '"Playing module ' i ' of ' Lister_NumSelEnt ':' X2C(0A) Temp_Name '" Next|Leave Playing|Stop'
  102.             Else
  103.                 dopus request '"Playing module ' i ' of ' Lister_NumSelEnt ':' X2C(0A) Temp_Name '" Next|Leave Playing'
  104.             IF RC = "0" THEN BreakIt = "YES"
  105.             IF RC = "2" THEN Do
  106.                 BreakIt = "YES"
  107.                 Quit_After = "NO"
  108.                 END
  109.             End
  110.  
  111.         Else Do
  112.             If Quit_After = "YES" Then
  113.                 dopus request '"Playing module ' i ' of ' Lister_NumSelEnt ':' X2C(0A) Temp_Name '" Leave Playing|Stop'
  114.             Else
  115.                 dopus request '"Playing module ' i ' of ' Lister_NumSelEnt ':' X2C(0A) Temp_Name '" Leave Playing'
  116.             IF RC = "1" Then Quit_After = "NO"
  117.             End
  118.  
  119.         IF BreakIt = "YES" THEN BREAK
  120.         END
  121.     End
  122.  
  123. ELSE Do
  124.     Address RXTRACKER Load FilePath;Address RXTRACKER Play
  125.     If Quit_After = "YES" Then
  126.         dopus request '"Playing module:' X2C(0A) FilePath'" Leave Playing|Stop'
  127.     Else
  128.         dopus request '"Playing module:' X2C(0A) FilePath'" Leave Playing'
  129.     IF RC ~= "0" THEN Quit_After = "NO"
  130.     End
  131.  
  132. /*-- Restore the Lister for normal use --------------------------------------*/
  133. syntax:;ioerr:                /* In case of error, jump here */
  134. END_PART_2:
  135. If FilePath = "" Then Do
  136.     lister refresh source_handle.0
  137.     lister set source_handle.0 busy 0
  138.     END
  139. END_PART:
  140. If Quit_After = "YES" Then Address RXTRACKER QUIT
  141.  
  142. EXIT
  143.