unit URealOne;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, OleCtrls, RealAudioObjects_TLB, ExtCtrls, ComCtrls, Menus;
type
TRealOneFrm = class(TForm)
OpenRMDlg: TOpenDialog;
Panel1: TPanel;
Panel2: TPanel;
OpenBtn: TButton;
PlayBtn: TButton;
PauseBtn: TButton;
StopBtn: TButton;
FullBtn: TButton;
MuteCheck: TCheckBox;
TrackBar1: TTrackBar;
Timer1: TTimer;
RepeatCheck: TCheckBox;
RealAudio1: TRealAudio;
StatusBar1: TStatusBar;
procedure OpenBtnClick(Sender: TObject);
procedure PlayBtnClick(Sender: TObject);
procedure PauseBtnClick(Sender: TObject);
procedure StopBtnClick(Sender: TObject);
procedure FullBtnClick(Sender: TObject);
procedure MuteCheckClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure TrackBar1Change(Sender: TObject);
private
EndPosition: Longint;
PauseFlag,DontSeek: Boolean;
{ Private declarations }
public
{ Public declarations }
end;
var
RealOneFrm: TRealOneFrm;
implementation
{$R *.DFM}
{=====================打开=========================}
procedure TRealOneFrm.OpenBtnClick(Sender: TObject);
begin
if OpenRMDlg.Execute then
begin
RealAudio1.SetSource(RealOneFrm.OpenRMDlg.FileName);
RealAudio1.DoPlay;
EndPosition := RealAudio1.GetLength;
RealAudio1.DoStop;
PlayBtn.Enabled := True;
PauseBtn.Enabled := False;
StopBtn.Enabled := False;
FullBtn.Enabled := False;
TrackBar1.Enabled := False;
Timer1.Enabled := False;
end;
end;
{=====================播放=========================}
procedure TRealOneFrm.PlayBtnClick(Sender: TObject);
begin
{设置图像窗口显示}
RealAudio1.SetControls('ImageWindow');
{显示图像窗口}
RealAudio1.Visible := True;
RealAudio1.DoPlay;
PlayBtn.Enabled := False;
OpenBtn.Enabled := False;
PauseBtn.Enabled := True;
StopBtn.Enabled := True;
FullBtn.Enabled := True;
Trackbar1.Enabled := True;
Timer1.Enabled := True;
PauseFlag := False;
RealAudio1.SetEnableContextMenu(False);
end;
{=====================暂停=========================}
procedure TRealOneFrm.PauseBtnClick(Sender: TObject);
begin
RealAudio1.DoPause;
PauseFlag := True;
PauseBtn.Enabled := False;
PlayBtn.Enabled := True;
FullBtn.Enabled := False;
end;
procedure TRealOneFrm.StopBtnClick(Sender: TObject);
begin
RealAudio1.DoStop;
PlayBtn.Enabled := True;
OpenBtn.Enabled := True;
PauseBtn.Enabled := False;
StopBtn.Enabled := False;
FullBtn.Enabled := False;
do
ntSeek := True;
TrackBar1.Position:=0;
do
ntSeek := False;
TrackBar1.Enabled := False;
Timer1.Enabled := False;
end;
//停止
procedure TRealOneFrm.FullBtnClick(Sender: TObject);
begin
RealOneFrm.RealAudio1.SetFullScreen;
end;
//设置全屏
procedure TRealOneFrm.MuteCheckClick(Sender: TObject);
begin
if MuteCheck.checked=true then
RealOneFrm.RealAudio1.SetMute(True)
else
RealOneFrm.RealAudio1.SetMute(False);
end;
procedure TRealOneFrm.FormCreate(Sender: TObject);
begin
PlayBtn.Enabled := False;
PauseBtn.Enabled := False;
StopBtn.Enabled := False;
OpenBtn.Enabled := True;
FullBtn.Enabled := False;
RealAudio1.SetMute(False);
Timer1.Enabled := False;
TrackBar1.Enabled := False;
OpenRMDlg.Filter := 'RealPlay Files(*.rm)|*.rm';
OpenRMDlg.Filter := RealOneFrm.OpenRMDlg.Filter + '|' + 'All Files(*.*)|*.*';
RealOneFrm.Caption := 'RealOne 播放器 -- KingLong Studio';
do
ntSeek := False;
PauseFlag := False;
end;
procedure TRealOneFrm.Timer1Timer(Sender: TObject);
begin
if TrackBar1.Enabled then
begin
do
ntSeek := True;
TrackBar1.Min := 0;
TrackBar1.Max := RealAudio1.GetLength;
TrackBar1.Position := RealAudio1.GetPosition;
do
ntSeek := False;
if (RealAudio1.GetPosition) = (Endposition) then
begin
StopBtnClick(Sender);
if Repeatcheck.Checked then
PlayBtnClick(Sender);
end;
end;
end;
procedure TRealOneFrm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
try
RealAudio1.DoStop;
except
RealOneFrm.Free;
end;
end;
procedure TRealOneFrm.TrackBar1Change(Sender: TObject);
begin
if not(DontSeek) then
begin
if not(PauseFlag) then
RealAudio1.Dopause;
RealAudio1.SetPosition(TrackBar1.Position);
if not(PauseFlag) then
RealAudio1.DoPlay;
end;
end;
end.