home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / kompon / d56 / MPEGPLUS.ZIP / MPEGplus / Main.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-08-02  |  3.0 KB  |  115 lines

  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, FileCtrl, ExtCtrls, MPEGplus;
  8.  
  9. type
  10.   TMainForm = class(TForm)
  11.     DriveList: TDriveComboBox;
  12.     FolderList: TDirectoryListBox;
  13.     FileList: TFileListBox;
  14.     CloseButton: TButton;
  15.     InfoBevel: TBevel;
  16.     IconImage: TImage;
  17.     ValidHeaderLabel: TLabel;
  18.     FileSizeLabel: TLabel;
  19.     ValidHeaderText: TEdit;
  20.     ChannelModeText: TEdit;
  21.     ChannelModeLabel: TLabel;
  22.     BitRateLabel: TLabel;
  23.     FrameCountLabel: TLabel;
  24.     DurationLabel: TLabel;
  25.     BitRateText: TEdit;
  26.     FrameCountText: TEdit;
  27.     DurationText: TEdit;
  28.     FileSizeText: TEdit;
  29.     TypeLabel: TLabel;
  30.     TypeText: TEdit;
  31.     procedure CloseButtonClick(Sender: TObject);
  32.     procedure FormCreate(Sender: TObject);
  33.     procedure FileListChange(Sender: TObject);
  34.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  35.   private
  36.     { Private declarations }
  37.     MPEGplus: TMPEGplus;
  38.     procedure ClearAll;
  39.   end;
  40.  
  41. var
  42.   MainForm: TMainForm;
  43.  
  44. implementation
  45.  
  46. {$R *.dfm}
  47.  
  48. procedure TMainForm.ClearAll;
  49. begin
  50.   { Clear all captions }
  51.   ValidHeaderText.Text := '';
  52.   ChannelModeText.Text := '';
  53.   FileSizeText.Text := '';
  54.   FrameCountText.Text := '';
  55.   BitRateText.Text := '';
  56.   TypeText.Text := '';
  57.   DurationText.Text := '';
  58. end;
  59.  
  60. procedure TMainForm.CloseButtonClick(Sender: TObject);
  61. begin
  62.   { Exit }
  63.   Close;
  64. end;
  65.  
  66. procedure TMainForm.FormCreate(Sender: TObject);
  67. begin
  68.   { Create object }
  69.   MPEGplus := TMPEGplus.Create;
  70.   { Reset captions }
  71.   ClearAll;
  72. end;
  73.  
  74. procedure TMainForm.FileListChange(Sender: TObject);
  75. begin
  76.   { Clear captions }
  77.   ClearAll;
  78.   if FileList.FileName = '' then exit;
  79.   if FileExists(FileList.FileName) then
  80.     { Load MPEGplus header }
  81.     if MPEGplus.ReadFromFile(FileList.FileName) then
  82.       if MPEGplus.Valid then
  83.       begin
  84.         { Fill captions }
  85.         ValidHeaderText.Text := 'Yes';
  86.         if MPEGplus.Corrupted then
  87.           ValidHeaderText.Text := ValidHeaderText.Text + ' (file corrupted)';
  88.         ChannelModeText.Text := MPEGplus.ChannelMode;
  89.         FileSizeText.Text := IntToStr(MPEGplus.FileSize) + ' bytes';
  90.         FrameCountText.Text := IntToStr(MPEGplus.FrameCount);
  91.         BitRateText.Text := IntToStr(MPEGplus.BitRate) + ' kbit';
  92.         TypeText.Text := 'Stream version ' + IntToStr(MPEGplus.StreamVersion);
  93.         if MPEGplus.StreamVersion = 7 then
  94.           TypeText.Text := TypeText.Text + ', profile ' + MPEGplus.Profile;
  95.         DurationText.Text := FormatFloat('.000', MPEGplus.Duration) + ' sec.';
  96.       end
  97.       else
  98.         { Header not found }
  99.         ValidHeaderText.Text := 'No'
  100.     else
  101.       { Read error }
  102.       ShowMessage('Can not read header in the file: ' + FileList.FileName)
  103.   else
  104.     { File does not exist }
  105.     ShowMessage('The file does not exist: ' + FileList.FileName);
  106. end;
  107.  
  108. procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
  109. begin
  110.   { Free memory }
  111.   MPEGplus.Free;
  112. end;
  113.  
  114. end.
  115.