/* mpega requestor GUI (c)1997 Ridwan Hughes
   Requires the RexxReqTools library

   Version 1.0

   Requires: c:mpega (version 2.4), c:run, c:break, c:wait and RexxReqTools
             from Aminet.

*/

call addlib("libs:rexxreqtools.library", 0, -30, 0)

fonttag=""
fname=""
fnamedisp=""
hz=2
playmode=1
qual=1
NL='0a'x
CL='0c'x
klicked=0

say CL

do forever
  if hz=1 then do
    hzdisp="44"
    hzopt1="22"
    hzopt2="11"
    hzsel1=2
    hzsel2=4
    end
  if hz=2 then do
    hzdisp="22"
    hzopt1="44"
    hzopt2="11"
    hzsel1=1
    hzsel2=4
    end
  if hz=4 then do
    hzdisp="11"
    hzopt1="44"
    hzopt2="22"
    hzsel1=1
    hzsel2=2
    end
  modedisp="Stereo"
  modesel="Mono"
  modespac=""
  if playmode=2 then do
    modedisp="Mono"
    modesel="Stereo"
    modespac="  "
    end
  if qual=2 then do
    qualdisp="Best"
    qualspac="   "
    qualsel1=1
    qualsel2=0
    end
  if qual=1 then do
    qualdisp="Medium"
    qualspac=" "
    qualsel1=2
    qualsel2=0
    end
  if qual=0 then do
    qualdisp="No"
    qualspac="     "
    qualsel1=2
    qualsel2=1
    end
  if klicked=7 then do
    if fname ~="" then do
      address command "break `status com c:mpega` <>nil:"
      address command "wait 0"
      say CL||NL||"*** Playing "||fname||" ***"
      say "*** At "||hzdisp||"khz, "||modedisp||", "||qualdisp||" sound quality enhancement ***"
      monno=''
      if playmode=2 then monno=' -m'
      address command 'run c:mpega -f0 -d'||hz||' -n -q'||qual||monno||' "'||fname||'"'
      end
    end
  call rtezrequest( "Name: "||fnamedisp||NL||,
                    "Freq: "||hzdisp||"khz"||" (Assuming using a 44khz file)   _ _   __   __"||NL||,
                    "Mode: "||modedisp||modespac||"                               | | | |  \ |    /\  /  / /"||NL||,
                    "Qual: "qual||" ("||qualdisp||" sound quality enhancement)"||qualspac||"|   | |--' |-  / _ /  / /"||NL||,
                    "                                           |   | |    |__ \_/ \_/ /"||NL||,
                    "Please select an option.                      -=-  Version 1.0  -=-",,
    hzopt1||"khz|"||hzopt2||"khz|"||modesel||"|Q"||qualsel1||"|Q"||qualsel2||"|Filename|Play|Quit", "Simple GUI for mpega, ©1997 Ridwan Hughes <fox@ridhughz.demon.co.uk>", fonttag "rtez_defaultresponse = 7, rt_reqpos = reqpos_centerscr")
  klicked=rtresult
  if klicked=1 then hz=hzsel1
  if klicked=2 then hz=hzsel2
  if klicked=3 then playmode=playmode+1
  if playmode=3 then playmode=1
  if klicked=4 then qual=qualsel1
  if klicked=5 then qual=qualsel2
  if klicked=6 then do
    filename = rtfilerequest(, , "Pick an mpeg 1/2/3 file" , , fonttag "rtfi_buffer = true")
    if rtresult ~= 0 then fname=filename
    fnamedisp=fname
    if length(fname)>63 then fnamedisp=right(fname,63)
    end
  if klicked=0 then do
    address command "break `status com c:mpega` <>nil:"
    leave
    end
  end

exit 0
