2007/10/01 | CMP3AudioTag
类别(计算机与编程) | 评论(0) | 阅读(2) | 发表于 04:53
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);
}
0

评论Comments

日志分类
首页[666]
计算机与编程[133]
EMU[40]
UFOs[24]
房产[127]
音乐[13]
LOG[0]
经济[120]
影视[3]
物理[7]
数学[8]
社会[105]
职场[9]
生物医学[18]
生活[59]