📄 utplaylist.~pas
字号:
unit UtPlayList;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ksthemeengine, te_controls, ksthemebuttons, ksthemepanels,
ksthemelistboxs, StdCtrls;
type
TPlayListFm = class(TForm)
PlayListPanel: TTeThemePanel;
OpenDialog1: TOpenDialog;
AddBtn: TTeThemeButton;
TeThemeEngine1: TTeThemeEngine;
ClearAllBtn: TTeThemeButton;
PlayListBox: TTeThemeListBox;
ShowListBox: TTeThemeListBox;
DeleteBtn: TTeThemeButton;
procedure AddBtnClick(Sender: TObject);
procedure PlayListPanelHide(Sender: TObject);
procedure DeleteBtnClick(Sender: TObject);
procedure ShowListBoxKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure ClearAllBtnClick(Sender: TObject);
procedure ShowListBoxDblClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ShowListBoxMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure ShowListBoxMouseLeave(Sender: TObject);
private
{ Private declarations }
playCount :integer;
public
{ Public declarations }
// ListFile :TList; //用于播放
end;
var
PlayListFm: TPlayListFm;
implementation
uses MessFr, mainfr, useexitwindll;
{$R *.dfm}
procedure TPlayListFm.AddBtnClick(Sender: TObject);
var
FilePath:string;
fileCount,LengthAll,lengthPart:integer;
begin
if OpenDialog1.Execute then
begin
PlayListBox.Visible := false;
for FileCount := 0 to OpenDialog1.Files.Count-1 do
begin
PLayListBox.Items.Append(OpenDialog1.Files[FileCount]);
end;
LengthPart := Length( ExtractFilePath(OpenDialog1.Files[0]) );
for FileCount := 0 to OpenDialog1.Files.Count-1 do
begin
LengthAll := Length(PlayListBox.Items[FileCount+playCount]);
FilePath := copy(PlayListBox.Items[FileCount+playcount],LengthPart+1,LengthAll-LengthPart+2);
ShowListBox.Items.Append(FilePath);
end;
playCount := PlayListBox.Items.Count;
end;
end;
procedure TPlayListFm.PlayListPanelHide(Sender: TObject);
begin
self.Hide;
end;
procedure TPlayListFm.DeleteBtnClick(Sender: TObject);
var
index :integer;
begin
index := ShowListBox.ItemIndex;
if index <> -1 then
begin
ShowListBox.Items.Delete(index);
PlayListBox.Items.Delete(index);
ShowListBox.ItemIndex := -1;
Mainform.CountSong := PlayListBox.Items.Count;
end;
end;
procedure TPlayListFm.ShowListBoxKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
index :integer;
begin
if Key <> VK_DELETE then
exit;
index := ShowListBox.ItemIndex;
if index <> -1 then
begin
ShowListBox.Items.Delete(index);
PlayListBox.Items.Delete(index);
Mainform.CountSong := PlayListBox.Items.Count;
end;
ShowListBox.ItemIndex := -1;
end;
procedure TPlayListFm.ClearAllBtnClick(Sender: TObject);
begin
ShowListBox.Clear;
PlayListBox.Clear;
Mainform.CountSong := 0;
PlayCount := 0;
end;
procedure TPlayListFm.ShowListBoxDblClick(Sender: TObject);
begin
try
pvStopMP3;
except
;
end;
mainform.next:= ShowListBox.ItemIndex-1;
mainform.SongTimer.Enabled := true;
mainform.SongTimerTimer(Sender);
end;
procedure TPlayListFm.FormClose(Sender: TObject; var Action: TCloseAction);
var
Filename :string;
pFile : TFileStream;
begin
Filename := ExtractFilePath(paramstr(0))+'PlayList.Dat';
pFile := TFileStream.Create(FileName,fmCreate);
PlayListBox.Items.SaveToStream(pFile);
pFile.Free;
end;
procedure TPlayListFm.FormShow(Sender: TObject);
var
Filename,FilePath :string;
pFile : TFileStream;
FileCount,LengthAll,LengthPart : integer;
begin
Filename := ExtractFilePath(paramstr(0))+'PlayList.Dat';
if (not FileExists(filename) ) then
exit;
pFile := TFileStream.Create(FileName,fmOpenRead);
PlayListBox.Items.LoadFromStream(pFile);
for FileCount := 0 to PlayListBox.Items.Count-1 do
begin
LengthAll := Length(PlayListBox.Items[FileCount]);
LengthPart := Length(ExtractFilePath( PlayListBox.Items[FileCount]));
FilePath := copy(PlayListBox.Items[FileCount],LengthPart+1,LengthAll-LengthPart+2);
ShowListBox.Items.Append(FilePath);
end;
pFile.Free;
end;
procedure TPlayListFm.FormCreate(Sender: TObject);
begin
Formshow(Sender);
end;
procedure TPlayListFm.ShowListBoxMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
ShowListBox.Selected[mainform.next] := true;
end;
procedure TPlayListFm.ShowListBoxMouseLeave(Sender: TObject);
begin
ShowListBox.Selected[mainform.next] := true;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -