/*Hip Module-Player v2.1 ?-?-1998 for Directory Opus 5.
  By Sampo Kytömäki (MY first AREXX program ever:)
  Email: sam@softavenue.fi

$VER: Play_HIP.dopus5 2.1 (24.11.98)

   To use it you may call it from the 'Double-click' function for the
   'Music module' filetype. Enter the following command:
   <ARexx> DOpus5:arexx/PlayMod_HIP.dopus5 {f}

   History:
   0.50 13-11-1995
   very buggy but works somehow

   0.70 13-11-1995
   now works fine

   0.80 13-12-1995
   some code cleanup

   1.00 14-12-1995
   Wou !!
   few bugs fixed

   2.00 04-08-1997
   added "Show/Hide samples" button
   added duration and other new things to module info
   added time limit to checkloop
   added instant play when loading hip (no list loading any more)
   fixed bugs (too many to mention)
   found and fixed major bug in hip loading, after two years :)

   2.01 09-01-98
   updated email address
   fixed for public release

   2.1 24-11-98
   uptated version number
   added rexxsupport.library loading
   fixed bug with filenames with gaps 
*/
                      
HIPPO='HD1:Music/HippoPlayer/HIP'   /* Path for your hippo*/

parse arg '"' module '"'
lf='0a'x
OPTIONS Results

if ~show('l','rexxsupport.library') then
   call addlib('rexxsupport.library',0,-30)

result = SHOW('Ports', 'HIPPOPLAYER')
if result=0 then DO
        ADDRESS DOPUS.1
         dopus request '"HippoPlayer is not Running!'lf'Loading HippoPlayer"' 'OK|Cancel'
          if RC = 1 then signal load
           end
           else signal play
           end
           else exit
        end
      end

info:
ADDRESS 'HIPPOPLAYER'
options results

get name
name = result

get fnam
fnam = result

get type
type = result

get size
size = result

get comm
comm = result

get csng
csng = result 

get nsng
nsng =  result

get mspo
mspo = result

get dura
if result == 0 then do
durt = "  Duration not available  "  "  "
end
else do
duration = result
	zero = ''             /* Duration format changing ripped  */
                             /*   from TotalDuration.hip         */
	hrs = ''            /* (C) Tomasz Kepa 09.VII.1996      */
	mins = duration % 60
	secs = duration // 60
	hours = mins % 60

	if secs < 10 then zero = '0'
	if mins >= 60 then mins = MINS - (HOURS * 60)
	if hours ~= 0 then
		do
			hrs = hours':'
                         end
			if mins < 10 then hrs = hrs'0'

durt = "  Duration: '"hrs''mins':'zero''secs"'"
end

signal infowindow

infowindow:
address 'DOPUS.1'
dopus request '"Module info'lf'¯¯¯¯¯¯¯¯¯¯¯¯¯¯'lf'Loaded module:' name''lf'Full name of the loaded module:' fnam''lf'Type of the loaded module:' type''lf'Size of the loaded module: 'size''lf'Filecomment for the loaded module:' comm''lf'Current song:' csng''lf'Number of songs:'nsng''lf'Maximum songposition:'mspo''lf''durt'" Quit|Stop|Leave Playing|Show/Hide Samples'
if RC = "1" THEN signal quit
if RC = "2" THEN signal stop
if RC = "3" THEN exit
else signal sample
   end
  end
 end
end

stop:
address 'HIPPOPLAYER'
stop
 exit

quit:
address 'HIPPOPLAYER'
stop
 quit
  exit

sample:
address 'HIPPOPLAYER'
 samples
  signal infowindow
   exit

play:
ADDRESS 'HIPPOPLAYER'
 play '"'module'"' 
  signal info

load:
ADDRESS COMMAND HIPPO '"'module'"'
  delay(50)
   If ~Show("P","HIPPOPLAYER") then do
    dopus request '"Error loading HippoPlayer!'lf'Check its command-path in the ARexx script." OK'
  end
 else signal info
end
