MP3 Info & Convert, Version 1.0 (alt)
Hinweis: dies ist nicht die neueste Version!
Datei: micmain.pas
{ micmain.pas This file is part of "Flocke's MP3 Info & Convert". Version 1.0 - Always find the most current version at http://flocke.vssd.de/prog/apps/pascal/mp3conv/ Copyright (C) 2005 Volker Siebert, Germany All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. } unit micmain; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, DropFilesTarget, Menus; type TfrmMain = class(TForm) mmoInfo: TMemo; btnConvert: TButton; cbxSound: TCheckBox; procedure cbxSoundClick(Sender: TObject); procedure FormHide(Sender: TObject); procedure btnConvertClick(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private-Deklarationen } FDropper: TDropFilesTarget; FInfoFilename: string; procedure SetInfoFilename(const Value: string); procedure FileDropped(Sender: TObject; Info: TDropFilesInfo); public { Public-Deklarationen } property InfoFilename: string read FInfoFilename write SetInfoFilename; end; var frmMain: TfrmMain; implementation {$R *.dfm} uses MMSystem, MP3Utils, micsave; procedure TfrmMain.SetInfoFilename(const Value: string); const CModes: array [0 .. 3] of string = ( 'Stereo', 'Joint Stereo', 'Dual Channel', 'Mono' ); YesNo: array [boolean] of string = ( 'No', 'Yes' ); var Header: TL3FHeader; Length: longint; procedure AddLn(const s: string); begin mmoInfo.Lines.Add(s); end; begin if Value <> FInfoFilename then begin FInfoFilename := Value; btnConvert.Enabled := false; mmoInfo.Lines.BeginUpdate; try mmoInfo.Lines.Clear; try Length := Layer3EstimateLength(FInfoFilename, Header); if Length = 0 then AddLn('No MP3-File') else begin AddLn('Valid MP3-File'); AddLn(''); AddLn('Filename: ' + FInfoFilename); AddLn(''); AddLn('Start: ' + IntToStr(Header.FileOffset) + ' (Byte)'); AddLn('Size: ' + IntToStr(Header.FileSize) + ' (Byte)'); AddLn('Length: ' + Format('%d:%2.2d.%3.3d', [Length div 60000, (Length div 1000) mod 60, Length mod 1000])); AddLn('Frames: ' + IntToStr(Header.TotalFrames)); AddLn('Samples: ' + IntToStr(Header.TotalFrames * Header.LengthInSamples)); AddLn('VBR (Xing): ' + YesNo[Header.XingHeader <> 0]); AddLn(''); AddLn('MPEG ' + IntToStr(2 - Header.Version) + ' Layer ' + IntToStr(4 - Header.Layer)); AddLn('Bitrate: ' + IntToStr(l3f_header_rate_kbps(Header)) + ' kbit/s'); AddLn('Frequency: ' + IntToStr(l3f_header_freq_hz(Header)) + ' Hz'); AddLn('Mode: ' + CModes[Header.Mode]); AddLn('Padding: ' + YesNo[Header.Padding <> 0]); AddLn('Emphasis: ' + YesNo[Header.Emphasis <> 0]); AddLn('CRC: ' + YesNo[Header.NoCrc = 0]); AddLn('Extension: ' + YesNo[Header.Extension <> 0]); AddLn('Copyright: ' + YesNo[Header.Copyright <> 0]); AddLn('Original: ' + YesNo[Header.Original <> 0]); AddLn(''); AddLn('Bytes/Frame: ' + IntToStr(Header.LengthInBytes)); AddLn('Samples/Frame: ' + IntToStr(Header.LengthInSamples)); btnConvert.Enabled := true; end; except on E: Exception do begin AddLn(''); AddLn('ERROR: ' + E.Message); end; end; finally mmoInfo.Lines.EndUpdate; end; end; end; procedure TfrmMain.FileDropped(Sender: TObject; Info: TDropFilesInfo); begin InfoFilename := Info.Files[0]; if Info.Files.Count > 1 then MessageDlg('Only one file at a time, please!', mtInformation, [mbOk], 0); end; procedure TfrmMain.FormCreate(Sender: TObject); var rs: TResourceStream; begin Icon.LoadFromResourceName(hInstance, 'MAINICON'); FDropper := TDropFilesTarget.Create(Self); FDropper.TargetControl := mmoInfo; FDropper.OnDropFiles := FileDropped; FDropper.Enabled := true; rs := TResourceStream.Create(hInstance, 'INFOTEXT', 'TEXT'); try mmoInfo.Lines.LoadFromStream(rs); finally rs.Free; end; end; procedure TfrmMain.btnConvertClick(Sender: TObject); begin if not btnConvert.Enabled then exit; ConvertThisFile(FInfoFilename); end; procedure TfrmMain.FormHide(Sender: TObject); begin PlaySound(nil, hInstance, 0); end; procedure TfrmMain.cbxSoundClick(Sender: TObject); begin if cbxSound.Checked then PlaySound('BACKGROUND', hInstance, SND_ASYNC or SND_LOOP or SND_RESOURCE) else PlaySound(nil, hInstance, 0); end; end. |