🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.multimedia
3 messages
3 total messages Started by Umut Besler Sat, 30 Mar 2002 15:42
Mp3 and video files
#984
Author: Umut Besler
Date: Sat, 30 Mar 2002 15:42
4 lines
1046 bytes
How can i get time, bitrate, IDTags of mp3 files
and how can i get time, resolution and codec avi files

thanks
Re: Mp3 and video files
#986
Author: Sander van Es
Date: Thu, 04 Apr 2002 13:42
8 lines
1002 bytes
Umut Besler wrote :
> How can i get time, bitrate, IDTags of mp3 files



for mp3tags, download : http://www.cobraweb.info/mp3tag.zip

Greatz Sander
Re: Mp3 and video files
#988
Author: ScOe
Date: Fri, 05 Apr 2002 10:36
166 lines
6698 bytes
"Umut Besler" <umutbesler@yahoo.com> wrote in message
news:3ca5dccd_2@dnews...
> How can i get time, bitrate, IDTags of mp3 files
> and how can i get time, resolution and codec avi files
>
> thanks
>
>


I'm usign following code for IDTag extracting where ID->Edit->Text is Edit
field where i show information

# define SHOWERRORANDQUIT Abort();
void __fastcall TMainForm::Mp3IDClick(TObject *Sender)
{
    HANDLE handle;  //handle to the mp3 file
    SECURITY_ATTRIBUTES security_attributes;  //need it to open a file
    HGLOBAL hFileBuffer;  //memory buffer
    DWORD dwBytesRead;  //bytes read
    ID3 tag;  //the ID3 information

    hFileBuffer = GlobalAlloc(GPTR, // object allocation attributes
                              128  // number of bytes to allocate
                             );

    if(!hFileBuffer)
      SHOWERRORANDQUIT;

    //fill in the security struct
    security_attributes.nLength              = sizeof(SECURITY_ATTRIBUTES);
    security_attributes.lpSecurityDescriptor = NULL;
    security_attributes.bInheritHandle       = FALSE;

    handle = CreateFile(FileListBox1->FileName.c_str(),  //the name
                        GENERIC_READ,  //we want to read
                        FILE_SHARE_READ,  //others can read it at the same
time
                        &security_attributes,  //security
                        OPEN_EXISTING,  //the file exists
                        FILE_ATTRIBUTE_NORMAL,  //normal attributes
                        NULL  //no template
                       );
    if(!handle)
      SHOWERRORANDQUIT;

    if(SetFilePointer(handle,  //handle of file
                      -128,  //number of bytes to move file pointer
                      NULL,  //address of high-order word of distance to
move
                      FILE_END  //how to move
                     ) == 0xFFFFFFFF)
      {
        CloseHandle(handle);
        SHOWERRORANDQUIT;
      }

    if(!ReadFile(handle,  //handle of file to read
                 GlobalLock(hFileBuffer), //address of buffer that receives
data
                 128,  //number of bytes to read
                 &dwBytesRead,  //address of number of bytes read
                 NULL  //address of structure for data
                ))
      {
        CloseHandle(handle);
        SHOWERRORANDQUIT;
      }
    CloseHandle(handle);

    //did we read 128 bytes?
    if(dwBytesRead != 128)
      SHOWERRORANDQUIT;

    //init the ID3 information
    if(!tag.Init(hFileBuffer))
      SHOWERRORANDQUIT;

ID->Edit1->Clear();
ID->Edit2->Clear();
ID->Edit3->Clear();
ID->Edit4->Clear();
ID->Edit5->Clear();
ID->Edit5->Clear();

AnsiString Title = tag.ReturnTitle();
AnsiString Artist = tag.ReturnArtist();
AnsiString Album = tag.ReturnAlbum();
AnsiString Comments = tag.ReturnComments();
int k = Title.Pos("  ");
int j = Artist.Pos("  ");
int l = Album.Pos("  ");
int m = Comments.Pos("  ");
Title.Delete(k,30);
Artist.Delete(j,30);
Album.Delete(l,30);
Comments.Delete(m,30);
ID->Edit1->Text = Title;
ID->Edit2->Text = Artist;
ID->Edit3->Text = Album;
ID->Edit4->Text = tag.ReturnYear();
ID->Edit5->Text = Comments;
ID->Edit6->Text = tag.ReturnGenre();
}
BOOL ID3::Init(HGLOBAL hglobal)
  {
    BYTE *lpByte = (BYTE*)GlobalLock(hglobal);

    const char genres[81][20] = {{"Blues"},{"Classic Rock"},{"Country"},
                                 {"Dance"},{"Disco"},{"Funk"},{"Grunge"},
                                 {"Hip-Hop"},{"Jazz"},{"Metal"},{"New Age"},

{"Oldies"},{"Other"},{"Pop"},{"R&B"},{"Rap"},

{"Reggae"},{"Rock"},{"Techno"},{"Industrial"},
                                 {"Alternative"},{"Ska"},{"Death Metal"},
                                 {"Pranks"},{"Soundtrack"},{"Euro-Techno"},
                                 {"Ambient"},{"Trip-Hop"},{"Vocal"},
                                 {"Jazz+Funk"},{"Fusion"},{"Trance"},
                                 {"Classical"},{"Instrumental"},{"Acid"},
                                 {"House"},{"Game"},{"Sound
Clip"},{"Gospel"},
                                 {"Noise"},{"AlternRock"},{"Bass"},{"Soul"},
                                 {"Punk"},{"Space"},{"Meditative"},
                                 {"Instrumental Pop"},{"Instrumental Rock"},
                                 {"Ethnic"},{"Gothic"},{"Darkwave"},
                                 {"Techno-Industrial"},{"Electronic"},
                                 {"Pop-Folk"},{"Eurodance"},{"Dream"},
                                 {"Southern Rock"},{"Comedy"},{"Cult"},
                                 {"Gangsta"},{"Top 40"},{"Christian Rap"},
                                 {"Pop/Funk"},{"Jungle"},{"Native
American"},
                                 {"Cabaret"},{"New Wave"},{"Psychadelic"},

{"Rave"},{"Showtunes"},{"Trailer"},{"Lo-Fi"},
                                 {"Tribal"},{"Acid Punk"},{"Acid Jazz"},
                                 {"Polka"},{"Retro"},{"Musical"},
                                 {"Rock & Roll"},{"Hard Rock"},{"Unknown"}};

    if(!((char)lpByte[0] == 'T' && (char)lpByte[1] == 'A' &&
         (char)lpByte[2] == 'G'))
    return FALSE;
    memcpy((void*)title,(void*)&lpByte[3],(size_t)30);
    memcpy((void*)artist,(void*)&lpByte[33],(size_t)30);
    memcpy((void*)album,(void*)&lpByte[63],(size_t)30);
    memcpy((void*)year,(void*)&lpByte[93],(size_t)4);
    memcpy((void*)comments,(void*)&lpByte[97],(size_t)30);

    if(lpByte[127] >= 0 && lpByte[127] < 80)
      lstrcpy(genre,genres[lpByte[127]]);
    //the genre is "Unknown"
    else
      lstrcpy(genre,genres[80]);

    title[30]    = '\0';
    artist[30]   = '\0';
    album[30]    = '\0';
    year[4]      = '\0';
    comments[30] = '\0';

    return TRUE;
}

Hope this helped !!
    Greet
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads