Thema: mp3 duration

Einzelnen Beitrag anzeigen

Benutzerbild von Gausi
Gausi

Registriert seit: 17. Jul 2005
847 Beiträge
 
Delphi 11 Alexandria
 
#3

Re: mp3 duration

  Alt 3. Apr 2009, 18:59
Hi again.

You can use Mp3FileUtils for this also.
Delphi-Quellcode:
var Id3v1Tag: TId3v1Tag;
  Id3v2Tag: TId3v2Tag;
  mpegInfo: TMpegInfo;
  stream: TFileStream;
begin
  stream := TFileStream.Create(aFileName, fmOpenRead or fmShareDenyWrite);
  Id3v2Tag.ReadFromStream(stream); // Read the id3v2Tag first (recommended, reading MPEG-Info will be much slower otherwise)

  // Seek to the end of the ID3Tag, if exists
  if Not Id3v2Tag.exists then
    stream.Seek(0, sobeginning)
  else
    stream.Seek(Id3v2Tag.size, soFromBeginning);

  // read MPEG-Information (like duration, bitrate, and so on)
  MpegInfo.LoadFromStream(Stream);

  // optionally: read the old id3v1-Tag
  Id3v1Tag.ReadFromStream(stream);
  stream.free;
end;
The duration (in seconds) is then stored in mpegInfo.Dauer ("Dauer" is german for "duration" - maybe I should change this. )
The angels have the phone box.
  Mit Zitat antworten Zitat