es.clear; RichEdit1.lines.add
(''演讲内容'');
end;
CurrentButton:=btPlay;
end;
btStop : begin CurrentButton:=btStop;
isend:=true;
end;
btpause: if CurrentButton=btPlay then
CurrentButton:=btpause
else if CurrentButton=btpause then
CurrentButton:=btPlay;
btPrev: begin CurrentButton:=btPrev;
Table1.Prior;
Position:=Table1.fieldvalues
[''STARTTIME''];
CurrentButton:=btPlay;
end;
btBack: begin CurrentButton:=btBack;
Table1.first; Position:=start;
CurrentPlay:=1;
CurrentDisp:=1;
RichEdit1.lines.clear;
RichEdit1.lines.add
(''演讲内容'');
CurrentButton:=btPlay;
end;
btNext: begin CurrentButton:=btNext;
Table1.Next;
Position:=Table1.fieldvalues
[''STARTTIME''];
CurrentButton:=btPlay;
end;
end;
case CurrentButton of
btPlay: Play;
btpause:pause;
btStop:Stop;
end;
end;
end;
---- 5、为了能同步显示文本,需要编写定时器OnTime事件的代码,如果当前播放的时间超过了当前记录的开始时间,则设置CurrentPlay为当前记录号,如果CurrentPlay超过了CurrentDisp ,则显示当前记录。
procedure TForm1.Timer1Timer(Sender: TObject);
begin
with MediaPlayer1 do
begin
if CurrentButton=btPlay then
begin
if not Table1.eof and (Position
>Table1.FieldValues[''STARTTIME''])
then
begin CurrentPlay:=Table1.recno;
if CurrentPlay >=CurrentDisp then
begin
RichEdit1.Lines.add(Table1.fieldvalues[''TEXT'']);
CurrentDisp:=CurrentDisp+1;
end;
Table1.Next;
end;
if Table1.eof then
begin
CurrentButton:=btStop;
isend:=true;
end;
end;
end;
end;
---- 注:在MediaPlayer的click事件中,使用了btPrev,btNext等常量,为了能够通过编译,在uses子句中需将ComCtrls放在mPlayer之前,以免引起冲突。