CMP3AudioTag

      计算机与编程 2007-10-1 4:53:00
bool CMP3AudioTag::Read(std::string filename)
{
  char header[4] = { 0 };
  char title[31] = { 0 };
  char artist[31] = { 0 };
  char album[31] = { 0 };
  char year[5] = { 0 };
  char comment[31] = { 0 };
  char genre = 0;
  int handle = open(filename.c_str(), O_RDONLY);
  lseek(handle, -128L, SEEK_END);
  read(handle, header, 3);
  bool result = false;
  if (!stricmp(header, "TAG")) {
    // valid header... this MP3 has an audio tag!
    read(handle, title, 30);      m_Title = title;
    read(handle, artist, 30);     m_Artist = artist;
    read(handle, album, 30);      m_Album = album;
    read(handle, year, 4);        m_Year = year;
    read(handle, comment, 30);    m_Comment = comment;
    read(handle, &genre, 1);
    m_Genre = (MP3_GENRE)genre; 
    m_GenreStr = GenreToString(m_Genre);
    result = true;
  }
  close(handle);
  return(result);
}
标签集:TAGS:
回复Comments() 点击Count()
喜欢就顶一下

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}