예제 #1
0
play_metadata_t play_meta(char* filename){
  ID3_Tag tag(filename);
  play_metadata_t result;
  memset(&result, 0, sizeof(play_metadata_t));

  field_text(&result.title, tag.Find(ID3FID_TITLE));
  field_text(&result.album, tag.Find(ID3FID_ALBUM));
  field_text(&result.artist, tag.Find(ID3FID_LEADARTIST));
  field_text(&result.tracknum, tag.Find(ID3FID_TRACKNUM));

  // If title is not set, set it to the filename (without extension)
  if(!result.title || strlen(result.title) == 0) {
    set_title_from_filename(&result.title, filename);
  }

  return result;
}
예제 #2
0
 void display_text_t::display(const model_type& value)
 {
     assert(window_m);
     value_m = value;
     window_m->SetText(field_text(name_m, value_m, label_color_m));
 }
예제 #3
0
void play_debug_meta(char* filename){
  ID3_Tag tag(filename);

  ID3_Tag::Iterator* iter = tag.CreateIterator();
  ID3_Frame* frame = NULL;
  char buf[1000];

  // Iconv conversion descriptor: UTF-16 -> UTF-8
  iconv_t cd = iconv_open("UTF8","UTF16BE");

  while (NULL != (frame = iter->GetNext()))
  {
    char* val = NULL;
    field_text(&val, frame); 
    printf("Frame: type %d %s %s:\n", frame->GetID(), frame->GetTextID(), frame->GetDescription());
    ID3_Frame::Iterator* fieldIter = frame->CreateIterator();
    ID3_Field* field = NULL;

    while (NULL != (field = fieldIter->GetNext())) {
      printf("  Field: type ");
      ID3_FieldType type = field->GetType();
      switch(type) {
      case ID3FTY_NONE:
        printf("none"); break;
      case ID3FTY_INTEGER:
        printf("int"); break;
      case ID3FTY_BINARY:
        printf("binary"); break;
      case ID3FTY_TEXTSTRING:
        field->Get(buf, 1000);
        printf("text with %d items, encoding ", field->GetNumTextItems());
        switch(field->GetEncoding()){
        case ID3TE_UTF16: printf("UTF-16"); 

          if ( cd != (iconv_t) -1 ) {
            char* in = (char*) field->GetRawUnicodeText();
            size_t insize = field->Size();

            char* bufptr = buf;
            size_t bufsize = 1000;
            size_t rc = 0;

            // Initialize iconv state
            if( iconv(cd, NULL, NULL, &bufptr, &bufsize) == (size_t) -1 ){
              printf("iconv init Failed\n");
            }
            if ( (rc = iconv(cd, &in, &insize, &bufptr, &bufsize)) != (size_t) -1 ) {
              *bufptr = '\0';
              printf(": '%s' (%d chars)\n", buf, rc);
            } else {
              printf("<conversion using iconv failed>");
              perror("iconv");
            }
          }
          break;
        case ID3TE_UTF16BE: printf("UTF-16BE"); 
          printf(": '%s'", buf);
          break;
        case ID3TE_UTF8: printf("UTF-8");
          printf(": '%s'", buf);
          break;
        case ID3TE_NONE: printf("none");
          printf(": '%s'", buf);
          break;
        case ID3TE_ISO8859_1: printf("ISO-8859-1/ASCII");
          printf(": '%s'", buf);
          break;
        }
        break;
      }
      printf("\n");
    }
    delete fieldIter;
    delete [] val;
  }
  delete iter;

  iconv_close(cd);
}