⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 delphi写的对学习delphi初级入门的数据编程很有用。是用用来查找硬盘mp3文件
💻 PAS
📖 第 1 页 / 共 2 页
字号:
// 清空播放列表文件
procedure TfrmPlayList.ClearPlayFile;
begin
  if FileCount <= 0 then exit; //如果列表中为空则退出
    MediaPlayer.Close;
    FileCount := 0;
    FileIndex := -1;
    FileListName.WriteInteger('播放文件', '文件数', FileCount);
    FileListName.WriteInteger('播放文件', '文件号', FileIndex);
    FileListName.EraseSection('文件列表');
    ListBox_PlayFiles.Items.Clear;
end;


procedure TfrmPlayList.FormCreate(Sender: TObject);
begin
  //Init;
end;

procedure TfrmPlayList.AutoPlayTimerTimer(Sender: TObject);
begin
  if MediaPlayer.Mode = mpPlaying then
  begin
    StepPosition(sender);
    if MediaPlayer.Position >= MediaPlayer.Length - 1000 then
    begin
     Button7.OnClick(Button7);
    end;
    //PlayNext;
  end;
end;
// 控制CDROM开关
procedure TfrmPlayList.CDControl;
begin
  if IsCDOpen then
  begin
    MciSendString('set cdaudio door closed', nil, 0, 0);
    IsCDOpen := False;
  end
  else
  begin
    MciSendString('set cdaudio door open', nil, 0, 0);
    IsCDOpen := True;
  end;
end;
// 倒退当前播放文件
procedure TfrmPlayList.PlayBack;
begin
  with MediaPlayer do
  begin
    if not(Mode in [mpPlaying]) then Exit;
    Pause;
    Position := Position - 6000;
    Play;
  end;
end;
// 暂停当前播放文件
procedure TfrmPlayList.PlayPause;
begin
  with MediaPlayer do
  begin
    if Mode in [mpOpen, mpPlaying] then Pause
    else if Mode in [mpOpen, mpPaused] then Resume;
  end;
end;
// 播放上一曲目
procedure TfrmPlayList.PlayPrev;
begin
  if FileIndex <= 0 then Exit;
  FileIndex := FileIndex - 1;
  ListBox_PlayFiles.ItemIndex := FileIndex;
  FileListName.WriteInteger('播放文件', '文件号', FileIndex);
  //PlayMedia;
end;
// 快进当前播放文件
procedure TfrmPlayList.PlayStep;
begin
  with MediaPlayer do
  begin
    if not(Mode in [mpPlaying]) then Exit;
    Pause;
    Position := Position + 6000;
    Play;
  end;
end;
// 停止当前播放文件
procedure TfrmPlayList.PlayStop;
begin
  with MediaPlayer do
  begin
    if Mode in [mpStopped] then Exit;
    Close;
  end;
end;

procedure TfrmPlayList.FormShow(Sender: TObject);
begin
  Self.Top := 170;
  Self.Left := Screen.Width div 2 - Self.Width div 2;
end;

procedure TfrmPlayList.Button5Click(Sender: TObject);
begin
PlayStep;
end;

procedure TfrmPlayList.Button4Click(Sender: TObject);
begin
PlayBack;
end;

procedure TfrmPlayList.RzTrackBar1Click(Sender: TObject);
var acurp: integer;
begin
  acurp := RzTrackBar1.Position;
  with MediaPlayer do
  begin
    if not(Mode in [mpPlaying]) then Exit;
    PlayPause;
    Pause;
    Position := acurp ;
    Play;
    IfDrag := false;
    AutoPlayTimer.Enabled := true;
  end;
end;

procedure TfrmPlayList.Button8Click(Sender: TObject);
 function GetFileIndxe(aFileName:string;aFile:TIniFile;aFileCount:integer ):integer;
 var x: integer;
 begin
  for x:=0 to aFileCount do
  begin
   if aFile.ReadString('文件列表','No.[' + IntToStr(x) + ']','')=aFileName then
   begin
   Result := x;
   exit;
   end;
  end;
 end;
var Index,rowindex: integer;
    aFileName: string ;
begin
  if not ifPause then
  begin
  rowindex := Frm_MP3Copy.cxGridDBTableView1.DataController.RecNo-1;;
  aFileName := Frm_MP3Copy.cxGridDBTableView1.DataController.GetValue(rowindex,6);
  //Index := GetFileIndxe(aFileName,frmPlayList.FileListName,frmPlayList.FileCount);
  //if Index < 0 then Exit;
  //if Index = FileIndex then Exit;
  //frmEPlayer.MediaPlayer.Close;
  //FileIndex := Index;
  //FileListName.WriteInteger('播放文件', '文件号', frmPlayList.FileIndex);
  PlayMedia(aFileName);
  end
  else
  begin
  with MediaPlayer do
  begin
    if Mode in [mpOpen, mpPaused] then play
    //else if Mode in [mpOpen, mpPaused] then Resume;
  end;
  ifPause := false;
  end;
end;

procedure TfrmPlayList.Button9Click(Sender: TObject);
begin
PlayStop;
RzTrackBar1.Position := 0;
ifPause := false;
end;

procedure TfrmPlayList.Button10Click(Sender: TObject);
begin
ifPause := true;
PlayPause;
end;

procedure TfrmPlayList.RzTrackBar1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
IfDrag := true;
AutoPlayTimer.Enabled := false;
end;

procedure TfrmPlayList.RzTrackBar1MouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
IfDrag := false;
AutoPlayTimer.Enabled := true;
end;

procedure TfrmPlayList.Button7Click(Sender: TObject);
 function GetFileIndxe(aFileName:string;aFile:TIniFile;aFileCount:integer ):integer;
 var x: integer;
 begin
  for x:=0 to aFileCount do
  begin
   if aFile.ReadString('文件列表','No.[' + IntToStr(x) + ']','')=aFileName then
   begin
   Result := x;
   exit;
   end;
  end;
 end;
var Index,rowindex: integer;
    aFileName: string ;
begin
  if Frm_MP3Copy.cxGridDBTableView1.DataController.RecNo=Frm_MP3Copy.cxGridDBTableView1.DataController.RowCount then exit;
  Frm_MP3Copy.cxGridDBTableView1.DataController.RecNo :=   Frm_MP3Copy.cxGridDBTableView1.DataController.RecNo+1;
  //Frm_MP3Copy.cxGridDBTableView1.DataController.IsRowSelected(Frm_MP3Copy.cxGridDBTableView1.DataController.RecNo-1);
  rowindex := Frm_MP3Copy.cxGridDBTableView1.DataController.RecNo-1;

  aFileName := Frm_MP3Copy.cxGridDBTableView1.DataController.GetValue(rowindex,6);

  //Index := GetFileIndxe(aFileName,frmPlayList.FileListName,frmPlayList.FileCount);
  //if Index < 0 then Exit;
  //if Index = FileIndex then Exit;
  //frmEPlayer.MediaPlayer.Close;
  //FileIndex := Index;
  //FileListName.WriteInteger('播放文件', '文件号', frmPlayList.FileIndex);
  PlayMedia(aFileName);
end;

procedure TfrmPlayList.Button6Click(Sender: TObject);
 function GetFileIndxe(aFileName:string;aFile:TIniFile;aFileCount:integer ):integer;
 var x: integer;
 begin
  for x:=0 to aFileCount do
  begin
   if aFile.ReadString('文件列表','No.[' + IntToStr(x) + ']','')=aFileName then
   begin
   Result := x;
   exit;
   end;
  end;
 end;
var Index,rowindex: integer;
    aFileName: string ;
begin
  if Frm_MP3Copy.cxGridDBTableView1.DataController.RecNo=1 then exit;
  Frm_MP3Copy.cxGridDBTableView1.DataController.RecNo :=   Frm_MP3Copy.cxGridDBTableView1.DataController.RecNo-1;
  //Frm_MP3Copy.cxGridDBTableView1.DataController.IsRowSelected(Frm_MP3Copy.cxGridDBTableView1.DataController.RecNo-1);
  rowindex := Frm_MP3Copy.cxGridDBTableView1.DataController.RecNo-1;

  aFileName := Frm_MP3Copy.cxGridDBTableView1.DataController.GetValue(rowindex,6);

  //Index := GetFileIndxe(aFileName,frmPlayList.FileListName,frmPlayList.FileCount);
  //if Index < 0 then Exit;
  //if Index = FileIndex then Exit;
  //frmEPlayer.MediaPlayer.Close;
  //FileIndex := Index;
  //FileListName.WriteInteger('播放文件', '文件号', frmPlayList.FileIndex);
  PlayMedia(aFileName);
end;

procedure TfrmPlayList.RzDBTrackBar1Change(Sender: TObject);
var 
  AUDIO_PARMS: MCI_DGV_SETAUDIO_PARMS; 
{$IFDEF _DEBUG} 
  ErrCode:DWord; 
  ErrText:array[0..1023]of char; 
{$ENDIF} 
begin 
  //Button1.Caption:=IntToStr(TrackBar1.Position);
  AUDIO_PARMS.dwValue:=RzDBTrackBar1.Position; // 看看这个参数
  AUDIO_PARMS.dwItem:=MCI_DGV_SETAUDIO_VOLUME;
{$IFDEF _DEBUG} 
  ErrCode:= 
{$ENDIF} 
  mciSendCommand(MediaPlayer.DeviceID,MCI_SETAUDIO,
                MCI_DGV_SETAUDIO_VALUE or MCI_DGV_SETAUDIO_ITEM, 
                DWord(@AUDIO_PARMS)); 
{$IFDEF _DEBUG} 
  mciGetErrorString(ErrCode,@ErrText,1024); 
  Caption:=StrPas(ErrText); 
{$ENDIF} 
end; 



end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -