home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magazyn Exec 5
/
CD_Magazyn_EXEC_nr_5.iso
/
Recent
/
mus
/
play
/
mp3Play.lha
/
mp3play
/
mp3Play
< prev
next >
Wrap
Text File
|
2001-06-03
|
2KB
|
125 lines
/*
mp3Play.rx © 2001 Carl Svensson
*/
if ~show("L","rexxreqtools.library") then
call addlib("rexxreqtools.library",5,-30)
if ~show("L","rexxsupport.library") then
call addlib("rexxsupport.library",0,-30,0)
/* set up vars */
wtitle="mp3Play"
btext="© 2001 Carl Svensson"
gdata="_Play|_Stop|_Quit"
cfg.prog="" /* path to mpega */
cfg.opts="" /* mpega options */
cfg.mp3d="" /* mp3 directory */
call readconfig()
tlist="rt_reqpos=reqpos_topleftscr rt_leftoffset=453 rt_topoffset=34"
choice=0
mp3file=""
playing=0
response.play=1
response.stop=2
response.quit=3
call gui()
exit;
/* ------ subs ------ */
gui: expose response.
choice=rtezrequest(btext,gdata,wtitle,tlist)
mp3file=""
select
when choice=response.play then
call play()
when choice=response.stop then
call stop(1)
otherwise
call quit()
end
return
quit:
if playing=1 then
call stop(0)
exit;
return
play: expose cfg.
if playing=1 then do
call stop(0)
end
if mp3file="" then do
call load()
end
address command "run <>nil: "cfg.prog" "cfg.opts" "mp3file" <>nil:"
playing=1
btext=stripfilename(mp3file)
call gui()
return
stop: expose cfg.
parse arg dogui
if checkfortask(cfg.prog) then
address command "break `status com="cfg.prog"`"
btext="No File"
playing=0
if dogui=1 then
call gui()
return
load: expose cfg.
mp3file=rtfilerequest(cfg.mp3d,"","Pick MP3")
call play()
return
stripfilename: procedure
parse arg fn
slash=lastpos("/",fn)
fname=substr(fn,slash+1)
return fname
readconfig: expose cfg.
if ~exists("s:mp3play.cfg") then do
say "No CFG file found"
exit
end
open(cfile,"s:mp3play.cfg","R")
cline=readln(cfile)
len=length(cline)
fsplit=pos(";",cline)+1
lsplit=lastpos(";",cline)+1
cfg.prog=substr(cline,1,fsplit-2)
cfg.mp3d=substr(cline,fsplit,lsplit-fsplit-1)
cfg.opts=substr(cline,lsplit)
close(cfile)
return
checkfortask: procedure
parse arg tname
if exists("env:c4t_out") then
delete("env:c4t_out")
address command "status com="tname" > env:c4t_out"
open(fptr,"env:c4t_out","R")
fdata=readln(fptr)
close(fptr)
if length(fdata)=0 then
running=0
else
running=1
return running