home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Books / 4 / EX11.ZIP / UNIT1.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-11-07  |  1.7 KB  |  89 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, ExtCtrls, Gauges, FileCtrl, StdCtrls, MPlayer;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     MediaPlayer1: TMediaPlayer;
  12.     CheckBox1: TCheckBox;
  13.     FileListBox1: TFileListBox;
  14.     DirectoryListBox1: TDirectoryListBox;
  15.     DriveComboBox1: TDriveComboBox;
  16.     FilterComboBox1: TFilterComboBox;
  17.     Panel1: TPanel;
  18.     Gauge1: TGauge;
  19.     Timer1: TTimer;
  20.     procedure FileListBox1DblClick(Sender: TObject);
  21.     procedure Timer1Timer(Sender: TObject);
  22.     procedure CheckBox1Click(Sender: TObject);
  23.     procedure Button1Click(Sender: TObject);
  24.   private
  25.     { Private declarations }
  26.   public
  27.     { Public declarations }
  28.   end;
  29.  
  30. var
  31.   Form1: TForm1;
  32.  
  33. implementation
  34.  
  35. {$R *.DFM}
  36.  
  37. procedure TForm1.FileListBox1DblClick(Sender: TObject);
  38. begin
  39.   with MediaPlayer1 do begin
  40.     Close;
  41.     Panel1.Refresh;
  42.     FileName:=FileListBox1.FileName;
  43.     Open;
  44.     Play;
  45.   end;
  46. end;
  47.  
  48. procedure TForm1.Timer1Timer(Sender: TObject);
  49. begin
  50.   with MediaPlayer1 do
  51.     if FileName<>'' then
  52.       Gauge1.Progress:=Round(100*Position/Length);
  53. end;
  54.  
  55. procedure TForm1.CheckBox1Click(Sender: TObject);
  56. var
  57.   Start_From : Longint;
  58. begin
  59.   with MediaPlayer1 do begin
  60.     if FileName='' then Exit;
  61.     Start_From:=Position;
  62.     Close;
  63.     Panel1.Refresh;
  64.  
  65.     if CheckBox1.Checked then
  66.       Display:=Panel1
  67.     else
  68.       Display:=NIL;
  69.  
  70.     Open;
  71.     Position:=Start_From;
  72.     Play;
  73.   end;
  74. end;
  75.  
  76. procedure TForm1.Button1Click(Sender: TObject);
  77. begin
  78.   if FileListBox1.FileName='' then Exit;
  79.   with MediaPlayer1 do begin
  80.     Close;
  81.     Panel1.Refresh;
  82.     FileName:=FileListBox1.FileName;
  83.     Open;
  84.   end;
  85.  
  86. end;
  87.  
  88. end.
  89.