📄 filelist.~pas
字号:
PlayMedia;
end;
procedure TFormFileList.ActionNextExecute(Sender: TObject);
begin
if FileIndex >=FileCount-1 then exit;
FileIndex :=FileIndex+1;
ListBox1.ItemIndex :=FileIndex;
FileListName.WriteInteger ('播放文件','文件号',FileIndex);
PlayMedia;
end;
procedure TFormFileList.ActionPauseExecute(Sender: TObject);
begin
with Mediaplayer1 do
begin
if mode in [mpOpen,mpPlaying] then pause
else if mode in [mpOpen,mpPaused] then resume;
end;
end;
procedure TFormFileList.ActionIndexUpExecute(Sender: TObject);
var
Tmp1, Tmp2:string;
Index:integer;
begin
Index := ListBox1.ItemIndex;
if Index<=0 then exit;
Tmp1:=FileListName.ReadString('文件列表','No.['+inttostr(Index)+']','');
Tmp2:=FileListName.ReadString('文件列表','No.['+inttostr(Index-1)+']','');
FileListName.WriteString('文件列表','No.['+inttostr(Index-1)+']',Tmp1);
FileListName.WriteString('文件列表','No.['+inttostr(Index)+']',Tmp2);
ListBox1.Items.Strings[index-1]:= Tmp1;
ListBox1.Items.Strings[index]:= Tmp2;
ListBox1.ItemIndex :=Index-1;
end;
procedure TFormFileList.ActionIndexdownExecute(Sender: TObject);
var
Tmp1, Tmp2 : string;
Index : integer;
begin
Index := ListBox1.ItemIndex;
if Index>=FileCount-1 then exit;
Tmp1:=FileListName.ReadString('文件列表','No.['+inttostr(Index)+']','');
Tmp2:=FileListName.ReadString('文件列表','No.['+inttostr(Index+1)+']','');
FileListName.WriteString('文件列表','No.['+inttostr(Index+1)+']',Tmp1);
FileListName.WriteString('文件列表','No.['+inttostr(Index)+']',Tmp2);
ListBox1.Items.Strings[index+1] := Tmp1;
ListBox1.Items.Strings[index] := Tmp2;
ListBox1.ItemIndex := Index+1;
end;
procedure TFormFileList.ListBox1DrawItem(Control: TWinControl;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
begin
Listbox1.Canvas.FillRect(Rect);
if odSelected in State then
begin
ListBox1.Canvas.Brush.Style := bsSolid;
end
else
ListBox1.canvas.Brush.Style := bsClear;
Listbox1.Canvas.TextOut(Rect.left,Rect.top,Listbox1.items.strings[index]);
end;
procedure TFormFileList.Image_upClick(Sender: TObject);
begin
ActionIndexUpExecute(Sender);
end;
procedure TFormFileList.Image_downClick(Sender: TObject);
begin
ActionIndexdownExecute(Sender);
end;
procedure TFormFileList.Image_hideClick(Sender: TObject);
begin
self.Hide;
end;
procedure TFormFileList.ActionAddExecute(Sender: TObject);
var
i:integer;
begin
OpenDialog1.Filter :='音频文件(*.WAV,*.MP3,*.WMA,*.MID,*.RMI,*.CDA)|*.WAV;*.MP3;*.WMA;*.MID;*.RMI;*.CDA|视频文件(*.MPG,*.AVI,*.DAT,*.ASF,*,MPEG)|*.MPG;*.AVI;*.DAT;*.ASF;*.MPEG|所有文件(*.*)|*.*';
if Opendialog1.Execute then
begin
with OpenDialog1.Files do
for I := 0 to Count-1 do
begin
ListBox1.Items.Add(strings[i]);
FileListName.WriteString('文件列表','No.['+inttostr(FileCount+i)+']',strings[i]);
end;
FileIndex := FileCount;
ListBox1.ItemIndex := FileIndex;
ListBoxScrollar(Sender);
FileCount :=FileCount+OpenDialog1.Files.Count;
FileListName.WriteInteger ('播放文件','文件号',FileIndex);
FileListName.WriteInteger ('播放文件','文件数',FileCount);
PlayMedia;
end;
end;
procedure TFormFileList.ActionClearExecute(Sender: TObject);
begin
if FileCount <= 0 then exit; //如果列表中为空则退出
Mediaplayer1.Close;
FileCount := 0;
FileIndex := -1;
FileListName.WriteInteger('播放文件','文件数',FileCount);
FileListName.WriteInteger('播放文件','文件号',FileIndex);
FileListName.EraseSection('文件列表');
ListBox1.Items.Clear;
end;
procedure TFormFileList.ActionDelExecute(Sender: TObject);
var
Index : Integer;
begin
if FileCount<=0 then exit; //如果列表中为空则退出
Index := ListBox1.ItemIndex;
if Index<0 then exit; //如果没有选择则退出
//如果被删除的是当前正在播放的音乐,则关闭音乐
if MediaPlayer1.FileName = ListBox1.Items.Strings[Index] then
begin
Mediaplayer1.Close;
FileIndex:=-1;
FileListName.WriteInteger('播放文件','文件号',FileIndex);
end;
//从列表中删除
ListBox1.Items.Delete(Index);
//列表文件总数减一
FileCount := FileCount-1;
if FileCount=0 then
begin
FileIndex := -1;
FileListName.WriteInteger('播放文件','文件号',FileIndex);
end;
if Index=FileCount then
ListBox1.ItemIndex :=0
else
ListBox1.ItemIndex:=index;
FileListName.WriteInteger('播放文件','文件数',FileCount);
for Index := Index to FileCount-1 do
begin
FileListName.WriteString ('文件列表','No.['+inttostr(Index)+']',
ListBox1.Items.Strings[Index]);
end;
ListBoxScrollar(Sender);
FileListName.DeleteKey('文件列表','No.['+inttostr(FileCount)+']');
end;
procedure TFormFileList.Image_addClick(Sender: TObject);
begin
ActionAdd.Execute;
end;
procedure TFormFileList.Image_delClick(Sender: TObject);
begin
ActionDel.Execute;
end;
procedure TFormFileList.Image_clearClick(Sender: TObject);
begin
ActionClear.Execute;
end;
procedure TFormFileList.ActionCdExecute(Sender: TObject);
begin
if CDopen then
begin
MciSendString('set cdaudio door closed', nil, 0, 0);
CDopen:=false;
end
else
begin
MciSendString('set cdaudio door open', nil, 0, 0);
CDopen:=true;
end;
end;
procedure TFormFileList.Timer1Timer(Sender: TObject);
begin
if Mediaplayer1.Mode =mpPlaying then
if Mediaplayer1.Position >=Mediaplayer1.Length -1000 then
ActionNext.Execute;
end;
procedure TFormFileList.Image_downMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
Image_down.Hint := '文件下移';
end;
procedure TFormFileList.Image_downMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Image_down.Left := Image_down.Left + 1;
Image_down.Top := Image_down.Top + 1;
end;
procedure TFormFileList.Image_downMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Image_down.Left := Image_down.Left - 1;
Image_down.Top := Image_down.Top - 1;
end;
procedure TFormFileList.Image_upMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Panel_up.Left := Panel_up.Left+1;
Panel_up.Top := Panel_up.Top+1;
end;
procedure TFormFileList.Image_upMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Panel_up.Left := Panel_up.Left-1;
Panel_up.Top := Panel_up.Top-1;
end;
procedure TFormFileList.Image_upMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
Image_up.Hint := '文件上移';
end;
procedure TFormFileList.Image_addMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Panel_add.Left := Panel_add.Left+1;
Panel_add.Top := Panel_add.Top+1;
end;
procedure TFormFileList.Image_addMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Panel_add.Left := Panel_add.Left-1;
Panel_add.Top := Panel_add.Top-1;
end;
procedure TFormFileList.Image_addMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
Image_add.Hint := '添加文件';
end;
procedure TFormFileList.Image_delMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Panel_del.Left := Panel_del.Left+1;
Panel_del.Top := Panel_del.Top+1;
end;
procedure TFormFileList.Image_delMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Panel_del.Left := Panel_del.Left-1;
Panel_del.Top := Panel_del.Top-1;
end;
procedure TFormFileList.Image_delMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
Image_del.Hint := '删除文件';
end;
procedure TFormFileList.Image_clearMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Panel_clear.Left := Panel_clear.Left+1;
Panel_clear.Top := Panel_clear.Top+1;
end;
procedure TFormFileList.Image_clearMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Panel_clear.Left := Panel_clear.Left-1;
Panel_clear.Top := Panel_clear.Top-1;
end;
procedure TFormFileList.Image_clearMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
Image_clear.Hint := '全部清除';
end;
procedure TFormFileList.Image_journerMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
Image_journer.Hint := '访问作者主页';
end;
procedure TFormFileList.Image_journerMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Panel_journer.Left := Panel_journer.Left+1;
Panel_journer.Top := Panel_journer.Top +1;
end;
procedure TFormFileList.Image_journerMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Panel_journer.Left := Panel_journer.Left -1;
Panel_journer.Top := Panel_journer.Top -1;
end;
procedure TFormFileList.Image_hideMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
Image_hide.Hint := '隐藏列表窗口';
end;
procedure TFormFileList.Image_hideMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Panel_hide.Left := Panel_hide.Left + 1;
Panel_hide.Top := Panel_hide.Top +1;
end;
procedure TFormFileList.Image_hideMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Panel_hide.Left := Panel_hide.Left - 1;
Panel_hide.Top := Panel_hide.Top - 1;
end;
procedure TFormFileList.Image_closeMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
Panel_close.Hint := '退出播放系统';
end;
procedure TFormFileList.Image_closeMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Panel_close.Left := Panel_close.Left+1;
Panel_close.Top := Panel_close.Top+1;
end;
procedure TFormFileList.Image_closeMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Panel_close.Left := Panel_close.Left - 1;
Panel_close.Top := Panel_close.Top - 1;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -