From: | Javier de las Rivas |
Date: | 24 May 2001 at 23:21:21 |
Subject: | [D5] CDDA |
made some chanes fell free to test/change/whatever you want
suggesions ideas
------------------------------
/*
$VER: CDDAscript.dopus5 1.4 (22.05.01) Javier de las Rivas <javierdlr@jazzfree.com>
Requires:
DOpus5 - GPSoftware
ACDB - AMINET
CDDA - AMINET
ShowTOC - AMINET
ed - Simple ASCII editor
Break - AmigaOS
Status - AmigaOS
Wait - AmigaOS
rexxsupport.library - AmigaOS
locale.library - AmigaOS (optional, for localization)
Note:
Configure your CDROM device and unit for CDDA using env-vars.
cdda_device: por defecto scsi.device
cdda_unit: por defecto 2
Example: SetEnv cdda_device blizzppc.device
*/
CDDAcmd="DH2:MUSICA/cdda VOL=200 PLAN=a"
TOCcmd="DH2:MUSICA/ShowTOC D=blizzppc.device U=2 CDIDDIR="
CDDBcmd="DH2:MUSICA/acdb DEVICE=blizzppc.device UNIT=2 HOST=us.cddb.com CDTIME=NO TRACKTIME=NO CLEANTEMP=YES TEMP=T: DISK="
EDcmd="C:ed -keepio"
CDIDdir="DH2:MUSICA/cddb/"
lf='0a'x
signal on halt
signal on syntax
signal on break_c
OPTIONS RESULTS
OPTIONS FAILAT 11
ADDRESS "DOPUS.1"
if ~SHOW('L', 'rexxsupport.library') THEN ADDLIB('rexxsupport.library',0,-30,0)
catalog=0
locale=1
IF ~SHOW('L', 'locale.library') THEN
IF ~ADDLIB('locale.library',0,-30,0) THEN locale=0
IF locale=1 THEN catalog=OPENCATALOG('CDDAscript.catalog','english',0)
FORBID()
myhandler='CDDAhandler.0'
IF SHOW('P', myhandler) THEN DO
PERMIT()
DOPUS REQUEST '"'GETSTR(5, 'You already have a lister open.')'" 'GETSTR(1, 'OK')
CLOSECATALOG(catalog)
EXIT 5
END
IF ~OPENPORT(myhandler) THEN DO
PERMIT()
DOPUS REQUEST '"'GETSTR(6, 'Unable to open MessagePort.')'" 'GETSTR(1, 'OK')
CLOSECATALOG(catalog)
EXIT 5
END
PERMIT()
/* Show the contents of the CD in a lister */
LISTER NEW
cdhandler=RESULT
ADDRESS COMMAND TOCcmd||CDIDdir' HEADFMT="%i*n%a*n%T" FMT="%y-%n (%dm:%02ds) - %t" NOTAIL >T:CDDAlist'
OPEN('listfile', 'T:CDDAlist', 'R')
cdidfile=READLN('listfile')
IF LEFT(cdidfile,10)='Error acce' THEN call CDEMPTY
artist=READLN('listfile')
IF artist='' THEN artist=GETSTR(8, 'Unknown')
cdtitle=READLN('listfile')
IF cdtitle='' THEN cdtitle=GETSTR(7, 'NoTitle')
LISTER SET cdhandler BUSY ON
LISTER SET cdhandler TOOLBAR 0
LISTER SET cdhandler LABEL 'CDDA'
LISTER SET cdhandler TITLE 'CDDAscript.dopus5'
LISTER SET cdhandler HEADER artist
LISTER SET cdhandler FIELD off
LISTER SET cdhandler FIELD 0 '"'cdtitle'"'
LISTER SET cdhandler FIELD on
LISTER SET cdhandler DISPLAY name
LISTER SET cdhandler HANDLER myhandler
/* Adding popupmenu options */
popup.count=2
popup.0=GETSTR(10, 'Play')
popup.1=GETSTR(11, 'Create CDID')
entry.menu=popup.
cdentry=READLN('listfile')
DO UNTIL EOF('listfile')
PARSE VAR cdentry type'-'numtim') - 'song
IF song='' THEN song=GETSTR(9, '<unknown>')
entry.name=numtim') - 'song
IF type='Audio' THEN LISTER ADDSTEM cdhandler entry.
cdentry=READLN('listfile')
END
LISTER SET cdhandler BUSY OFF
LISTER REFRESH cdhandler FULL
CLOSE('listfile')
DELETE('T:CDDAlist')
/* Check if the CD is only DataCD */
LISTER QUERY cdhandler NUMFILES
IF RESULT=0 THEN DO
DOPUS REQUEST '"'GETSTR(12, 'Inserted CD is only DataCD.')'" 'GETSTR(1, 'OK')
call BREAK_C
END
/* Wait for doubleclickin' on an entry */
DO FOREVER
IF WAITPKT(myhandler) THEN DO
packet=GETPKT(myhandler)
IF packet~='00000000'x THEN DO
event=GETARG(packet,0)
fname=GETARG(packet,2)
arg3=GETARG(packet,3)
SELECT
WHEN EVENT='inactive' THEN LEAVE
WHEN EVENT='doubleclick' | (EVENT='menu' & arg3=0) THEN call PLAYTRACK(fname)
WHEN EVENT='menu' & arg3=1 THEN call CREATECDID
OTHERWISE LISTER REQUEST cdhandler '"'GETSTR(17, 'Unrecognised command.')'" 'GETSTR(1, 'OK')
END
END
REPLY(packet,0)
END
END
call BREAK_C
/* Play the selected track */
PLAYTRACK:
cdtrack=arg(1)
PARSE VAR cdtrack track' ('mins':'segs') - 'song
seconds=(60*mins)+segs
ADDRESS COMMAND 'Run >T:CDDAproc 'CDDAcmd' TRACK='track
/* Getting process # of CDDA */
OPEN('procfile', 'T:CDDAproc', 'R')
process=READLN('procfile')
PARSE VAR process '[CLI 'proceso']'
CLOSE('procfile')
DELETE('T:CDDAproc')
/* Do we have problems with CDDA? */
ADDRESS COMMAND 'Wait 2 SEC'
ADDRESS COMMAND 'Status >NIL: 'proceso
IF RC~=0 THEN call CDDABAD
/* No problems, so we continue... */
LISTER SET cdhandler BUSY ON
LISTER SET cdhandler NEWPROGRESS INFO ABORT
LISTER SET cdhandler NEWPROGRESS TITLE GETSTR(13, 'Playing track')' 'track'...'
IF song=GETSTR(9, '<unknown>') THEN
LISTER SET cdhandler NEWPROGRESS INFO '0:00'
ELSE LISTER SET cdhandler NEWPROGRESS INFO song' 0:00'
/* Wait until song is ended or user abort */
cseg=0
cmin=0
count=0
aborted=0
Time('R')
DO WHILE aborted=0 & count<seconds
Delay(50)
count=TRUNC(TIME('E'))
cseg=count-(60*cmin)
IF cseg>59 THEN DO
cmin=cmin+1
cseg=0
END
zseg=cseg
IF LENGTH(cseg)<2 THEN zseg="0"cseg
IF song=GETSTR(9, '<unknown>') THEN
LISTER SET cdhandler NEWPROGRESS INFO cmin':'zseg
ELSE LISTER SET cdhandler NEWPROGRESS INFO song' 'cmin':'zseg
LISTER QUERY cdhandler ABORT
aborted=RESULT
IF aborted=1 THEN ADDRESS COMMAND 'Break >NIL: 'proceso
END
LISTER SET cdhandler BUSY OFF
RETURN
/* Create a CDID file */
CREATECDID:
DOPUS REQUEST '"'GETSTR(15, 'Manual: With an EDITOR you create the CDID file.'lf||'Auto: Use InternetCDDB to download the CDID file.')'" 'GETSTR(16, 'Manual|Auto|Exit')
IF DOPUSRC=0 THEN RETURN
ELSE IF DOPUSRC=1 THEN DO
DOPUS REQUEST '"'GETSTR(14,'Create CDID'lf||lf'File format to create:'lf||'Line 1: Artist/Group name'lf||'Line 2: Album title'lf||'Further lines: Songs names')'" 'GETSTR(1, 'OK')
ADDRESS COMMAND EDcmd' 'CDIDdir||cdidfile
END
ELSE DO
dopus request '"Cooming soon.'lf||'Muy pronto." 'GETSTR(1, 'OK')
/*
IF ~SHOW('P', 'ACDB')THEN DO
ADDRESS COMMAND 'Run >NIL: 'CDDBcmd||cddadir
WAITFORPORT 'ACDB'
END
ADDRESS COMMAND "rx '"'address 'ACDB'; cdid store; download all'"'"
*/
END
RETURN
/* Localization */
GETSTR:
PARSE ARG msgno, msgstring
IF catalog~=0 THEN msgstring=GETCATALOGSTR(catalog,msgno,msgstring)
RETURN msgstring
/* No CD */
CDEMPTY:
CLOSE('listfile')
DELETE('T:CDDAlist')
DOPUS REQUEST '"'GETSTR(19, 'Please, insert an AudioCD.')'" 'GETSTR(1, 'OK')
call BREAK_C
/* CDDA not properly configured */
CDDABAD:
DOPUS REQUEST '"'GETSTR(20, 'CDDA not properly configured.')'" 'GETSTR(1, 'OK')
call BREAK_C
/* Exit or Ctrl+C */
HALT:
SYNTAX:
BREAK_C:
LISTER QUERY cdhandler BUSY
IF RESULT=1 THEN DO
ADDRESS COMMAND 'Break >NIL: 'proceso
LISTER SET cdhandler BUSY OFF
END
IF catalog~=0 THEN CLOSECATALOG(catalog)
LISTER CLOSE cdhandler
CLOSEPORT(myhandler)
EXIT
---------------------