home *** CD-ROM | disk | FTP | other *** search
- /**/
-
- 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="listview"
- listview.Class="NListview"
- listview.List="List"
- list.Title=ParseText("%cTrack|Type|Start|End|Time")
- list.Format=ParseText("PREPARSE=%r BAR W=-1,PREPARSE=%c BAR W=-1,PREPARSE=%c BAR W=-1,PREPARSE=%c BAR W=-1,W=-1")
-
- 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 set("win","Sleep",1)
- call DoMethod("list","Clear")
- call set("Info","Contents","Reading TOC...")
- res = CDTOC(global.device,"db","global.toc")
- if res>0 then do
- call set("Info","Contents","Can't read TOC")
- call set("Play","Disabled",1)
- call set("PlayAll","Disabled",1)
- call set("win","Sleep",0)
- return
- end
- call set("list","Quiet",1)
- do i=0 to global.toc.num-1
- if global.toc.i.Audio then type=ParseText("%bAudio")
- else type="Data"
- entry=i+1 || "|" || type || "|" || 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 set("list","Active",GetActive())
- call set("Info","Contents","TOC read")
- call set("win","Sleep",0)
- call set("Play","Disabled",0)
- call set("PlayAll","Disabled",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
- res=CDPlay(global.device,"db",a,a)
- 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
- /**************************************************************************/
-
-