/**/ signal on halt signal on break_c call Init call CreateApp call ReadTOC call HandleApp /* never reached */ /***********************************************************************/ Init: procedure expose global. l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit if AddLibrary("rxmui.library","rxcd.library")~=0 then exit call RxMUIOpt("debugmode showerr") global.device="cd0" return /***********************************************************************/ HandleApp: procedure expose global. ctrl_c=2**12 do forever call NewHandle("app","h",ctrl_c) if and(h.signals,ctrl_c)>0 then exit if h.EventFlag then select when h.event="QUIT" then exit otherwise interpret h.event end end /* never reached */ /***********************************************************************/ CreateApp: procedure expose global. app.Title="RxCDTOCExample" app.Version="$VER: RxCDTOCExample 1.0 (18.9.2001)" app.Copyright="Copyright 2001 by Alfonso Ranieri" app.Author="Alfonso Ranieri" app.Description="RxCD TOC Example" app.Base="RXMUIEXAMPLE" app.SubWindow="win" win.ID="MAIN" win.Title="RxCD TOC" win.Contents="mgroup" mgroup.0="cdg" cdg.Class="Group" cdg.Horiz=1 cdg.0=Label("_Device") cdg.1=String("Device",'d',global.device) mgroup.1="dg" dg.Class="Group" dg.Frame="Group" dg.Background="GroupBack" dg.0="atg" atg.Class="Group" atg.ShowMe=0 atg.Columns=2 atg.0=label("Title") atg.1=Text("Title") atg.2=label("Artist") atg.3=Text("Artist") dg.1="listview" listview.Class="NListview" listview.List="List" list.Title=ParseText("%cTrack|Title|Start|End|Time") list.Format=ParseText("PREPARSE=%r BAR W=-1,PREPARSE=%c BAR W=-1 COL=2,PREPARSE=%c BAR W=-1 COL=3,W=-1 COL=4") ig.Class="Group" ig.Columns=2 ig.Frame="Group" ig.FrameTitle="Status" ig.0=Label("AudioStatus") ig.1=Text("AudioStatus") ig.2=Label("Flags") ig.3=Text("Flags") ig.4=Label("Track") ig.5=Text("Track") ig.6=Label("Index") ig.7=Text("Index") ig.8=Label("Abs Address") ig.9=Text("AbsAddr") ig.10=Label("Rel Address") ig.11=Text("RelAddr") mgroup.2=Text("Info","TOC") mgroup.3="bg" bg.Class="Group" bg.Horiz=1 bg.0=Button("TOC","_TOC") Play.Disabled=1 bg.1=Button("Play","_Play") PlayAll.Disabled=1 bg.2=Button("PlayAll","Play _All") bg.3=Button("Quit","_Quit") if NewObj("application","app")>0 then exit call Notify("win","CloseRequest",1,"app","ReturnID","quit") call Notify("device","NewContents","EveryTime","app","SetVar","global.device","TriggerValue") call Notify("device","NewContents","EveryTime","app","Return","call ReadTOC") call Notify("TOC","Pressed",0,"app","Return","call ReadTOC") call Notify("Play","Pressed",0,"app","Return","call PlayFun('ACTIVE')") call Notify("PlayAll","Pressed",0,"app","Return","call PlayFun('ALL')") call Notify("quit","Pressed",0,"app","ReturnID","Quit") call Notify("list","DoubleClick","EveryTime","app","Return","call PlayFun('ACTIVE')") call set("win","open",1) if ~xget("win","open") then do say "can't open window" exit end return /***********************************************************************/ halt: break_c: exit /**************************************************************************/ ReadTOC: procedure expose global. call ResetObjects call set("win","Sleep",1) res=CDTOC(global.device,"db","global.toc") if res>0 & db.SenseKey=6 then res = CDTOC(global.device,"db","global.toc") if res>0 then do call ObjectsStatus("BAD",db.Error db.Reasone) call set("win","Sleep",0) return end global.cddb=(CDDBGet("global.toc")==0) call set("list","Quiet",1) do i=0 to global.toc.num-1 if ~global.toc.i.Audio then iterate entry=i+1 if global.cddb then entry=entry || "|" global.toc.i.Title else entry=entry || "|" entry=entry || "|" || format(global.toc.i.StartMin,global.toc.i.StartSec) || "|" || EndFun(global.toc.i.StartAddr,global.toc.i.Frames) || "|" || format(global.toc.i.Min,global.toc.i.Sec) call DoMethod("list","Insert",entry,"Bottom") end call set("list","Quiet",0) call ObjectsStatus("OK","TOC read") call set("win","Sleep",0) return /**************************************************************************/ format: procedure parse arg m,s return right("00" || m,2)":"right("00" || s,2) /**************************************************************************/ EndFun: procedure parse arg a,b f=a+b s=f%75 m=s%60 s=s//60 return format(m,s) /**************************************************************************/ PlayFun: procedure expose global. parse arg what select when what="ACTIVE" then do a=xget("list","active")+1 track=global.toc.a.Track res=CDPlay(global.device,"db",track,track) if res>0 then call set("Info","Contents","Can't play track" a) else call set("Info","Contents","Playing track" a) end when what="ALL" then do res=CDPlay(global.device,"db") if res>0 then call set("Info","Contents","Can't play tracks") else call set("Info","Contents","Playing tracks") end end return /**************************************************************************/ GetActive: procedure expose global. res = CDStatus(global.device,"db","status") if res=0 & status.AudioStatus=17 then return status.Track-1 return 0 /**************************************************************************/ ResetObjects: procedure expose global. call DoMethod("list","Clear") call set("Title","Contents","") call set("Artist","Contents","") call set("Info","Contents","Reading TOC...") return /**************************************************************************/ ObjectsStatus: procedure expose global. parse arg status,msg select when status="OK" then do call set("list","Active",GetActive()) call set("Info","Contents","TOC read") call set("Play","Disabled",0) call set("PlayAll","Disabled",0) if global.cddb then do call set("Title","Contents",global.toc.Title) call set("Artist","Contents",global.toc.Artist) call set("list","Format",ParseText("PREPARSE=%r BAR W=-1,BAR W=-1,PREPARSE=%c BAR W=-1,PREPARSE=%c BAR W=-1,W=-1")) call set("atg","ShowMe",1) end else do call set("list","Format",ParseText("PREPARSE=%r BAR W=-1,PREPARSE=%c BAR W=-1 COL=2,PREPARSE=%c BAR W=-1 COL=3,W=-1 COL=4")) call set("atg","ShowMe",0) end end when status="BAD" then do call set("Info","Contents","Can't read TOC ["msg"]") call set("Play","Disabled",1) call set("PlayAll","Disabled",1) end end return /**************************************************************************/