📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, FileCtrl, ExtCtrls, MPlayer, Menus;
type
TForm1 = class(TForm)
MediaPlayer1: TMediaPlayer;
Panel1: TPanel;
DriveComboBox1: TDriveComboBox;
DirectoryListBox1: TDirectoryListBox;
FilterComboBox1: TFilterComboBox;
FileListBox1: TFileListBox;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure FileListBox1Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
FileExt:String[4];
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FileListBox1Click(Sender: TObject);
begin
FileExt:=AnsiLowerCase(ExtractFileExt(Filelistbox1.FileName));
if FileExt='.wav' then
begin
panel1.caption:='播放声音';
MediaPlayer1.Close;
MediaPlayer1.FileName:=filelistbox1.FileName;
MediaPlayer1.Open;
MediaPlayer1.Play;
end
else
if FileExt='.avi' then
begin
with MediaPlayer1 do
begin
close;
display:=panel1;
filename:=filelistbox1.FileName;
panel1.caption:='';
open;
Rewind;
play;
end;
end
else
if FileExt='.ado' then
begin
panel1.Caption:='播放音乐';
Mediaplayer1.Close;
mediaplayer1.FileName:=filelistbox1.FileName;
mediaplayer1.Open;
mediaplayer1.Play;
end;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
if filelistbox1.ItemIndex<>-1 then
begin
mediaplayer1.Rewind;
mediaplayer1.Play;
end
else
messagedlg('请选择你要播放的文件!',mtwarning,[mbyes],0);
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -