📄 unit1.~pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, WMPLib_TLB, StdCtrls, ExtCtrls, Buttons, ComCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
wmp: TWindowsMediaPlayer;
OpenDialog1: TOpenDialog;
Button2: TButton;
Timer1: TTimer;
BitBtn1: TBitBtn;
ListBox2: TListBox;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure ListBox1DblClick(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
num,i:Integer;
begin
if opendialog1.Execute then
begin
num:=opendialog1.Files.Count;
showmessage(inttostr(num));
if num<>4405496 then //判断是否没有选择文件??
for i:=0 to num-1 do
begin
//ListBox1.Items.Append(ExtractFileName(OpenDialog1.Files[i]));
listbox2.Items.append(OpenDialog1.Files.Strings[i]);
//listbox1.items.append(ExtractFileName(listbox2.Items[i])); // 用于文件方式加载
//下面是打开方式加载,不然列表会出错
listbox1.Items.append(ExtractFileName(OpenDialog1.Files.Strings[i]));
end;
//if listbox1.Items.count>0 then
showmessage(inttostr(listbox1.Items.count));
// showmessage('df');
listbox1.itemindex:=0;
listbox2.itemindex:=listbox1.itemindex;
wmp.URL:=listbox2.Items[listbox2.itemindex];
end;
end;
procedure TForm1.ListBox1Click(Sender: TObject);
begin
//wmp.URL:=listbox1.Items[listbox1.itemindex];
//wmp.URL:=ExtractFileName(OpenDialog1.Files[listbox1.itemindex]);
//wmp.URL:=OpenDialog1.Files.Strings[listbox1.itemindex]
end;
procedure TForm1.ListBox1DblClick(Sender: TObject);
begin
//wmp.URL:=listbox1.Items[listbox1.itemindex];
//wmp.URL:=ExtractFileName(OpenDialog1.Files[listbox1.itemindex]);
//wmp.URL:=OpenDialog1.Files.Strings[listbox1.itemindex]
// ShowMessage('111');
listbox2.itemindex:=listbox1.itemindex;
wmp.URL:=listbox2.Items[listbox2.itemindex];
//showmessage(listbox2.Items[listbox2.itemindex]); 显示当前列表曲目
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
//showmessage('你好');
//listbox2.Items.SaveToFile('c:\wsk.ini')
//showmessage(ExtractFilePath(Application.EXEName)); //当前目径
listbox2.Items.SaveToFile(ExtractFilePath(Application.EXEName)+'\mp3.ini');
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
//timer1.Interval:=wmp.controls.curr
//wmp.status 状态显示,正在播放XX歌,XX kb
//wmp.controls.currentPositionString 当前播放进度
//wmp.currentMedia.name 状态名歌名
//wmp.Parent.Name 窗体名
//showmessage('df');
if wmp.status='已停止' then
begin
//wmp.playState
//wmp.URL:=OpenDialog1.Files.Strings[listbox1.itemindex+1]
//wmp.controls.play;
listbox1.ItemIndex:=listbox1.ItemIndex+1;
if listbox1.itemindex>=listbox1.Items.Count-1 then
begin
listbox1.itemindex:=0;
end;
wmp.URL:=listbox2.Items[listbox1.itemindex];
end;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
//wmp.controls.play
//showmessage(WMP.status);
if listbox1.Items.Count>0 then
showmessage('测试成功');
if listbox1.Items.count=0 then
showmessage('数据为空');
end;
procedure TForm1.Button3Click(Sender: TObject);
var
li,lnum:integer;
begin
listbox2.Clear;
listbox1.Clear;
listbox2.Items.LoadFromFile(ExtractFilePath(application.exename)+'\mp3.ini');
lnum:=listbox2.Items.Count;
if listbox2.items.count>0 then
for li:=0 to lnum-1 do
begin
//showmessage(inttostr(lnum)); 测试个数
listbox1.Items.Append(EXtractfilename(listbox2.Items[li]));
end;
if listbox1.Items.count>0 then
begin
// showmessage(inttostr(listbox1.items.count));
listbox1.ItemIndex:=0;
wmp.URL:=listbox2.Items[listbox1.itemindex];
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -