📄 unit1.pas
字号:
var
ts2:string;
begin
ts2:=GetStringFromFrame(tend*25);
SetLength(ts2,length(ts2)-3);
edit2.Text:=ts2;
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
key:=#0;
end;
procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
key:=#0;
end;
procedure TForm1.loopClick(Sender: TObject); //设置循环
begin
if tloop=true then
begin
tloop:=false;
loop.Font.Color:=clgreen;
form2.CheckBox1.Checked:=false;
end
else
begin
tloop:=true;
loop.Font.Color:=clred;
form2.CheckBox1.Checked:=true;
end;
end;
procedure tform1.play();
begin
if (pos('.wma',MediaPlayer1.FileName)<>0)or(pos('.mid',MediaPlayer1.FileName)<>0) or(pos('.mp3',MediaPlayer1.FileName)<>0) or (pos('.wav',MediaPlayer1.FileName)<>0)or(pos('.WMA',MediaPlayer1.FileName)<>0)or(pos('.MID',MediaPlayer1.FileName)<>0) or(pos('.MP3',MediaPlayer1.FileName)<>0) or (pos('.WAV',MediaPlayer1.FileName)<>0) then
begin
try
form3mp3;
Timer1.Enabled:=true;
except
Timer1.Enabled:=false;
abort;
end
end
else
begin
Form4.Label1.Caption:='不能识别该文件! ';
form4.ShowModal;
MediaPlayer1.FileName:='';
abort;
end;
end;
procedure TForm1.tiaoxingcloClick(Sender: TObject);
begin
form3.Close;
tiaoxingopen.Visible:=true;
tiaoxingclo.Visible:=false;
n5.Checked:=false;
end;
procedure TForm1.lastClick(Sender: TObject); //播放上一首歌曲
begin
if CheckListBox1.Count<>0 then
if CheckListBox1.ItemIndex=0 then
begin
MediaPlayer1.FileName:=CheckListBox1.Items.Strings[integer(CheckListBox1.ItemIndex)];
Form1.play;
time2;
opentag:=true;
CheckListBox1.ItemIndex:=0;
end
else
begin
CheckListBox1.ItemIndex:=CheckListBox1.ItemIndex-1;
MediaPlayer1.FileName:=CheckListBox1.Items.Strings[integer(CheckListBox1.ItemIndex)];
Form1.play;
time2;
opentag:=true;
end;
end;
procedure TForm1.nextClick(Sender: TObject);
begin
if CheckListBox1.Count<>0 then
if CheckListBox1.ItemIndex+1=CheckListBox1.Count then
begin
MediaPlayer1.FileName:=CheckListBox1.Items.Strings[integer(CheckListBox1.ItemIndex)];
Form1.play;
time2;
opentag:=true;
CheckListBox1.ItemIndex:=CheckListBox1.Count;
end
else
begin
CheckListBox1.ItemIndex:=CheckListBox1.ItemIndex+1;
MediaPlayer1.FileName:=CheckListBox1.Items.Strings[integer(CheckListBox1.ItemIndex)];
Form1.play;
time2;
opentag:=true;
end;
end;
procedure tform1.form3mp3; /////选择播放方式
begin
if (pos('.mp3',MediaPlayer1.FileName)<>0)or(pos('.wav',MediaPlayer1.FileName)<>0)or(pos('.MP3',MediaPlayer1.FileName)<>0)or(pos('.WAV',MediaPlayer1.FileName)<>0) then
begin
pvStopMp3;
pvInitMp3(hinstance,form3.Panel2.Handle,form3.Panel2.Width,form3.Panel2.Height,32);
if (fshi=false)and(opentag=true) then
begin
MediaPlayer1.Stop;
MediaPlayer1.Close;
end;
try
pvPlayMp3(pchar(MediaPlayer1.FileName));
opentag:=true;
except
Form4.Label1.Caption:='播放文件时发生错误! ';
form4.ShowModal;
MediaPlayer1.FileName:='';
Timer1.Enabled:=false;
edit1.Text:='00:00:00';
tend:=0;
tlen:=0;
time2;
jindu.Progress:=0;
abort;
end;
fshi:=true;
time;
end
else if (pos('.wma',MediaPlayer1.FileName)<>0)or(pos('.mid',MediaPlayer1.FileName)<>0)or(pos('.WMA',MediaPlayer1.FileName)<>0)or(pos('.MID',MediaPlayer1.FileName)<>0) then
begin
if (fshi=true)and(opentag=true) then
begin
pvStopMp3;
end;
try
MediaPlayer1.Open;
MediaPlayer1.Play;
except
Form4.Label1.Caption:='播放文件时发生错误! ';
form4.ShowModal;
MediaPlayer1.FileName:='';
MediaPlayer1.Close;
edit1.Text:='00:00:00';
jindu.Progress:=0;
Timer1.Enabled:=false;
tend:=0;
time2;
abort;
end;
fshi:=false;
opentag:=true;
time;
end
else
begin
Form4.Label1.Caption:='不能识别该文件类型! ';
form4.ShowModal;
abort;
end;
end;
procedure TForm1.N17Click(Sender: TObject);
Begin
BitBtn7.Click;
end;
procedure TForm1.N18Click(Sender: TObject);
begin
CheckListBox1.Clear;
CheckListBox1.Items.SaveToFile(ExtractFileDir(application.ExeName)+'\mplay.dll');
end;
procedure TForm1.N15Click(Sender: TObject);
begin
BitBtn6.Click;
end;
procedure TForm1.N1Click(Sender: TObject);
begin
BitBtn6.Click;
end;
procedure TForm1.N5Click(Sender: TObject);
begin
if n5.Checked=false then
begin
tiaoxingopen.Click;
n5.Checked:=true;
end
else
begin
tiaoxingclo.Click;
n5.Checked:=false;
end;
end;
procedure TForm1.N6Click(Sender: TObject);
begin
if n6.Checked=false then
begin
BitBtn10.Click;
n6.Checked:=true;
end
else
begin
BitBtn5.Click;
n6.Checked:=false;
end;
end;
procedure TForm1.N8Click(Sender: TObject);
begin
BitBtn1.Click;
end;
procedure TForm1.N14Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.shipinClick(Sender: TObject); //打开视频播放
begin
form1.Hide;
shipinform.Show;
shipin.Visible:=false;
n2.Checked:=true;
end;
procedure TForm1.WMGetMinMaxInfo( var Msg :TWMGetMinMaxInfo );
begin
with Msg.MinMaxInfo^ do
begin
ptMaxSize.X := 281; {最大化时宽度}
ptMaxSize.Y := 368; {最大化时高度}
ptMaxPosition.X := form1.Left; {最大化时左上角横坐标}
ptMaxPosition.Y := Form1.Top; {最大化时左上角纵坐标}
ptMinTrackSize:=point(281,368);
ptMaxTrackSize:=point(281,368);
end;
Msg.Result := 0; {告诉Windows你改变了 minmaxinfo}
inherited;
end;
procedure TForm1.BitBtn8Click(Sender: TObject); //关闭视频播放
begin
form1.Hide;
form6.Show;
end;
procedure TForm1.N2Click(Sender: TObject);
begin
shipin.Click;
n2.Checked:=true;
end;
procedure TForm1.DragFileProc(var Message: TMessage); //拖动文件播放功能实现;
var
FileNum: Word;
p: array[0..254] of char;
begin
if Message.Msg =WM_DropFiles then
begin
FileNum := DragQueryFile(Message.WParam,$FFFFFFFF,nil,0);
for FileNum := 0 to FileNum - 1 do
begin
DragQueryFile(Message.WParam, FileNum , p ,255);
mediaplayer1.FileName:=strpas(p);//加入播放.
try
if (pos('.mp3',MediaPlayer1.FileName)<>0)or(pos('.wav',MediaPlayer1.FileName)<>0)or(pos('.mid',MediaPlayer1.FileName)<>0)or(pos('.wma',MediaPlayer1.FileName)<>0) or (pos('.MP3',MediaPlayer1.FileName)<>0)or(pos('.WAV',MediaPlayer1.FileName)<>0)or(pos('.MID',MediaPlayer1.FileName)<>0)or(pos('.WMA',MediaPlayer1.FileName)<>0)then
begin
Timer1.Enabled:=false;
form1.play;
opentag:=true;
CheckListBox1.Items.Add(MediaPlayer1.FileName);
CheckListBox1.ItemIndex:=CheckListBox1.Count-1;
CheckListBox1.Items.SaveToFile(ExtractFileDir(Application.ExeName)+'\mplay.dll');
end
else if (pos('.mpg',MediaPlayer1.FileName)<>0)or(pos('.avi',MediaPlayer1.FileName)<>0)or (pos('.MPG',MediaPlayer1.FileName)<>0)or(pos('.AVI',MediaPlayer1.FileName)<>0)then
begin
Timer1.Enabled:=false;
MediaPlayer1.Open;
mediaplayer1.play;
BitBtn2.Font.Color:=clred;
BitBtn3.Font.Color:=clteal;
mpg:=true;
fshi:=false;
opentag:=true;
pvStopMp3;
edit1.Text:='00:00:00';
tend:=0;
tlen:=0;
time2;
jindu.Progress:=0;
end
else
begin
Form4.Label1.Caption:='不能播放该文件! ';
form4.ShowModal;
abort;
end;
except
MediaPlayer1.FileName:='';
Timer1.Enabled:=false;
edit1.Text:='00:00:00';
tend:=0;
tlen:=0;
time2;
jindu.Progress:=0;
abort;
end;
end;
end
else
begin
OLDWndProc(Message);
end;
end;
procedure TForm1.CheckListBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_delete then
begin
BitBtn7.Click
end
else if (key=$41)and(shift=[ssctrl]) then
begin
BitBtn6.Click;
end
else if (key=$43)and(shift=[ssctrl]) then
begin
BitBtn4.Click;
end
else if (key=$4C)and(shift=[ssctrl]) then
begin
last.Click;
end
else if (key=$4E)and(shift=[ssctrl]) then
begin
next.Click;
end
else if (key=$4F)and(shift=[ssctrl]) then
begin
BitBtn1.Click;
end
else if (key=$50)and(shift=[ssctrl]) then
begin
BitBtn3.Click;
end
else if (key=$54)and(shift=[ssctrl]) then
begin
tiaoxingopen.Click;
end
else if (key=$4B)and(shift=[ssctrl]) then
begin
BitBtn5.Click;
end
else if key=vk_RETURN then
begin
BitBtn2.Click;
end;
end;
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_delete then
begin
BitBtn7.Click
end
else if (key=$41)and(shift=[ssctrl]) then
begin
BitBtn6.Click;
end
else if (key=$43)and(shift=[ssctrl]) then
begin
BitBtn4.Click;
end
else if (key=$4C)and(shift=[ssctrl]) then
begin
last.Click;
end
else if (key=$4E)and(shift=[ssctrl]) then
begin
next.Click;
end
else if (key=$4F)and(shift=[ssctrl]) then
begin
BitBtn1.Click;
end
else if (key=$50)and(shift=[ssctrl]) then
begin
BitBtn3.Click;
end
else if (key=$54)and(shift=[ssctrl]) then
begin
tiaoxingopen.Click;
end
else if (key=$4B)and(shift=[ssctrl]) then
begin
BitBtn5.Click;
end
else if key=vk_RETURN then
begin
BitBtn2.Click;
end;
end;
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_delete then
begin
BitBtn7.Click
end
else if (key=$41)and(shift=[ssctrl]) then
begin
BitBtn6.Click;
end
else if (key=$43)and(shift=[ssctrl]) then
begin
BitBtn4.Click;
end
else if (key=$4C)and(shift=[ssctrl]) then
begin
last.Click;
end
else if (key=$4E)and(shift=[ssctrl]) then
begin
next.Click;
end
else if (key=$4F)and(shift=[ssctrl]) then
begin
BitBtn1.Click;
end
else if (key=$50)and(shift=[ssctrl]) then
begin
BitBtn3.Click;
end
else if (key=$54)and(shift=[ssctrl]) then
begin
tiaoxingopen.Click;
end
else if (key=$4B)and(shift=[ssctrl]) then
begin
BitBtn5.Click;
end
else if key=vk_RETURN then
begin
BitBtn2.Click;
end;
end;
procedure TForm1.Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_delete then
begin
BitBtn7.Click
end
else if (key=$41)and(shift=[ssctrl]) then
begin
BitBtn6.Click;
end
else if (key=$43)and(shift=[ssctrl]) then
begin
BitBtn4.Click;
end
else if (key=$4C)and(shift=[ssctrl]) then
begin
last.Click;
end
else if (key=$4E)and(shift=[ssctrl]) then
begin
next.Click;
end
else if (key=$4F)and(shift=[ssctrl]) then
begin
BitBtn1.Click;
end
else if (key=$50)and(shift=[ssctrl]) then
begin
BitBtn3.Click;
end
else if (key=$54)and(shift=[ssctrl]) then
begin
tiaoxingopen.Click;
end
else if (key=$4B)and(shift=[ssctrl]) then
begin
BitBtn5.Click;
end
else if key=vk_RETURN then
begin
BitBtn2.Click;
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
PopupMenu1.Items.Items[4].Enabled:=true;
end;
procedure TForm1.N9Click(Sender: TObject);
begin
BitBtn8.Click;
end;
procedure TForm1.N12Click(Sender: TObject);
begin
form7.Show;
end;
procedure TForm1.N11Click(Sender: TObject);
begin
form8.Show;
end;
procedure TForm1.N16Click(Sender: TObject);
begin
form9.ShowModal;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
UnregisterHotKey(handle,id);
GlobalDeleteAtom(id);
end;
procedure TForm1.BitBtn9Click(Sender: TObject);
begin
form1.Visible:=false;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -