返回
{***************************************************************}
{*** FVision Unit Version1.0 ***}
{*** 蓝蚂蚁工作室 ***}
{***************************************************************}
{*** CD播放器单元 ***}
{***************************************************************}
Unit FCDPlay;
Interface
Uses
Dos,FTool,FEvent,FView,FExtDrv,FControl,FCDDrv;
Type
PCDPlay=^TCDPlay;
TCDPlay=object(TWindow)
Timer:PTimer;
TotMus,TotTime,CurMus,CurTime:PStaticText;
MSmg,SSmg:PMulSmg;
Constructor Init;
Procedure FlushInfo;
Procedure HandleEvent(Var Event:TEvent);Virtual;
end;
Implementation
Constructor TCDPlay.Init;
var
R:TRect;
begin
AssignRect(R,0,0,300,150);
Inherited Init(R,'CD播放器',True);
IsValid:=CDExist;
GetCDDrvInfo;
GetCDStatus;
GetMusStart(CD_Cur_Music);
AssignRect(R,20,35,280,55);
Insert(New(PShape,Init(gcBroad+gcHideMouse,R,0,0,$0A,0,'')));
AssignRect(R,20,60,280,80);
Insert(New(PShape,Init(gcBroad+gcHideMouse,R,0,0,$0A,0,'')));
Insert(New(PStaticText,Init(stNormal+stFColor,22,38,'曲数: 总时间:',$A0)));
Insert(New(PStaticText,Init(stNormal+stFColor,22,63,'当前曲目: 当前时间:',$A0)));
TotMus:=New(PStaticText,Init(stNormal+stFColor,65,38,IntStr(CDMusNum),$A4));
TotTime:=New(PStaticText,Init(stNormal+stFColor,200,38,Int_Str(CDMinute,2)+':'+Int_Str(CDSecond,2),$A4));
CurMus:=New(PStaticText,Init(stNormal+stFColor,100,63,IntStr(CD_Cur_Music),$A4));
CurTime:=New(PStaticText,Init(stNormal+stFColor,200,63,Int_Str(CD_All_Minute,2)+':'+Int_Str(CD_All_Second,2),$A4));
Insert(TotMus);
Insert(TotTime);
Insert(CurMus);
Insert(CurTime);
AssignRect(R,20,90,121,131);
Insert(New(PShape,Init(gcBroad+gcHideMouse,R,0,0,$0,0,'')));
MSmg:=New(PMulSmg,Init(23,93,2,CD_Cur_Minute,SMG_MIDDLE,0));
SSmg:=New(PMulSmg,Init(75,93,2,CD_Cur_Second,SMG_MIDDLE,0));
Insert(MSmg);
Insert(SSmg);
AssignRect(R,130,90,280,131);
Insert(New(PShape,Init(gcDBroad+gcHideMouse,R,0,0,0,0,'')));
Insert(New(PButton,Init(140,100,160,120,'£',kbAltP,cmPlay)));
Insert(New(PButton,Init(162,100,182,120,'⊙',kbAltS,cmStop)));
Insert(New(PButton,Init(184,100,204,120,#17#17,kbHome,cmHead)));
Insert(New(PButton,Init(206,100,226,120,'',kbLeft,cmPrev)));
Insert(New(PButton,Init(228,100,248,120,'',kbRight,cmNext)));
Insert(New(PButton,Init(250,100,270,120,#16#16,kbEnd,cmTail)));
Timer:=New(PTimer,Init(100));
Insert(Timer);
Next;
Center;
end;
Procedure TCDPlay.FlushInfo;
begin
GetCDStatus;
GetCDDrvInfo;
GetMusStart(CD_Cur_Music);
TotMus^.Modify(IntStr(CDMusNum));
TotTime^.Modify(Int_Str(CDMinute,2)+':'+Int_Str(CDSecond,2));
CurMus^.Modify(IntStr(CD_Cur_Music));
CurTime^.Modify(Int_Str(CD_All_Minute,2)+':'+Int_Str(CD_All_Second,2));
MSmg^.Modify(CD_Cur_Minute);
SSmg^.Modify(CD_Cur_Second);
Timer^.Reset;
end;
Procedure TCDPlay.HandleEvent;
begin
Inherited HandleEvent(Event);
case Event.What of
evCommand : case Event.Command of
cmTimer:if Event.InfoPtr=Timer then FlushInfo;
cmPlay:PlayCD(CD_Cur_Music,True,True);
cmStop:StopCD;
cmHead:begin
StopCD;
PlayCD(1,False,True);
end;
cmTail:begin
StopCD;
PlayCD(CDMusNum,False,True);
end;
cmNext:if CD_Cur_Music<CDMusNum then
begin
StopCD;
PlayCD(CD_Cur_Music+1,False,True);
end;
cmPrev:if CD_Cur_Music>1 then
begin
StopCD;
PlayCD(CD_Cur_Music-1,False,True);
end;
else Exit;
end;
else Exit;
end;
ClearEvent(Event);
end;
end.