Thanks! That got me on the right track. I'd completely missed the Test folder :P, and was just looking in examples. Here's my code. The trick is you create your FileRef object with a new TagLib::MPEG::File object instead of the plain string, like so:<br>
<br>    TagLib::FileRef f( new MPEG::File( argv[argc - 1] ) );<br><br>Then when you get the file object from the list of File Refs you can cast it to a TagLib::MPEG::File and call it's special 'save' method that lets you set version:<br>
<br>    TagLib::MPEG::File *mpegFile = (TagLib::MPEG::File*)(*it).file();<br>    mpegFile->save(MPEG::File::AllTags, true, 3);<br><br>Here's the full code. The only wrinkle here is I've modified the original sample tagger to take the incoming strings as base64 values as an ugly hack to get around Windows XP's lousy Unicode support on the  Command line :P. I'm pretty sure I can ditch this though.<br>
<br>#include <iostream><br>#include <string.h><br><br>#include <stdio.h><br>#include <sys/types.h><br>#include <sys/stat.h><br>#include <stdlib.h><br><br>#include <tlist.h><br>#include <fileref.h><br>
#include <tfile.h><br>#include <tag.h><br>#include <id3v2tag.h><br>#include <mpegfile.h><br><br><br>#include <Poco/URI.h><br><br>#include "Poco/TextConverter.h"<br>#include "Poco/ASCIIEncoding.h"<br>
#include "Poco/UTF8Encoding.h"<br>#include "Poco/UTF16Encoding.h"<br>#include "Poco/UnicodeConverter.h"<br>using Poco::TextConverter;<br>using Poco::ASCIIEncoding;<br>using Poco::UTF8Encoding;<br>
using Poco::UTF16Encoding;<br><br><br>using namespace std;<br>using namespace TagLib;<br><br>bool isArgument(const char *s)<br>{<br>  return strlen(s) == 2 && s[0] == '-';<br>}<br><br>bool isFile(const char *s)<br>
{<br>  struct stat st;<br>#ifdef _WIN32<br>  return ::stat(s, &st) == 0 && (st.st_mode & (S_IFREG));<br>#else<br>  return ::stat(s, &st) == 0 && (st.st_mode & (S_IFREG | S_IFLNK));<br>#endif<br>
}<br><br>void usage()<br>{<br>  cout << endl;<br>  cout << "Usage: tagwriter <fields> <files>" << endl;<br>  cout << endl;<br>  cout << "Where the valid fields are:" << endl;<br>
  cout << "  -t <title>"   << endl;<br>  cout << "  -a <artist>"  << endl;<br>  cout << "  -A <album>"   << endl;<br>  cout << "  -c <comment>" << endl;<br>
  cout << "  -g <genre>"   << endl;<br>  cout << "  -y <year>"    << endl;<br>  cout << "  -T <track>"   << endl;<br>  cout << endl;<br>
<br>  exit(1);<br>}<br><br>int main(int argc, char *argv[])<br>{<br>  TagLib::List<TagLib::FileRef> fileList;<br><br>  while(argc > 0 && isFile(argv[argc - 1])) {<br><br>    TagLib::FileRef f( new MPEG::File( argv[argc - 1] ) );<br>
<br>    if(!f.isNull() && f.tag())<br>      fileList.append(f);<br><br>    argc--;<br>  }<br><br>  if(fileList.isEmpty())<br>    usage();<br><br>  <br>  <br>  for(int i = 1; i < argc - 1; i += 2) {<br><br>    if(isArgument(argv[i]) && i + 1 < argc && !isArgument(argv[i + 1])) {<br>
<br>      <br>      <br>      char field = argv[i][1];<br><br>    std::string decoded;<br>    std::wstring decoded16;<br><br>    Poco::URI::decode ( argv[i + 1] , decoded ) ;<br><br>    const char* mp3FileName;<br><br>    Poco::UnicodeConverter::toUTF16(decoded, decoded16);<br>
<br>    TagLib::String value ( decoded16 );<br>    <br>    cout << "Decoded Value " << decoded << endl;<br>    <br>      TagLib::List<TagLib::FileRef>::Iterator it;<br>      for(it = fileList.begin(); it != fileList.end(); ++it) {<br>
<br>    cout << "file name found " << endl;<br><br>    <br>        TagLib::Tag *t = (*it).tag();<br>        <br>        switch (field) {<br>        case 't':<br>          t->setTitle(value);<br>
          break;<br>        case 'a':<br>          t->setArtist(value);<br>          break;<br>        case 'A':<br>          t->setAlbum(value);<br>          break;<br>        case 'c':<br>          t->setComment(value);<br>
          break;<br>        case 'g':<br>          t->setGenre(value);<br>          break;<br>        case 'y':<br>          t->setYear(value.toInt());<br>          break;<br>        case 'T':<br>
          t->setTrack(value.toInt());<br>          break;<br>        default:<br>          usage();<br>          break;<br>        }//END SWITCH STATEMENT*/<br>    <br>    <br>      }//END FOR LOOP<br>    }else<br>      usage();<br>
  }//end if-else<br><br>  TagLib::List<TagLib::FileRef>::Iterator it;<br>  for(it = fileList.begin(); it != fileList.end(); ++it){<br>    <br>    TagLib::MPEG::File *mpegFile = (TagLib::MPEG::File*)(*it).file();<br>
    mpegFile->save(MPEG::File::AllTags, true, 3);<br>    //(*it).file()->save();<br>    <br>  }<br><br>  return 0;<br>}//END MAIN<br><br><br>To build the above run:<br><br>g++ ./mid3lib_tagger.cpp -o encTagwriter -L/use/local/lib/ -I/usr/local/include/taglib -ltag -lPocoFoundation -lPocoUtil -lPocoXML -lPocoNet `llvm-config --libs core` `llvm-config --ldflags` <br>
<br>You'll need to install Poco statically, but that's pretty easy :P<br><br><div class="gmail_quote">On Fri, Nov 16, 2012 at 7:09 PM, Neil Hodge <span dir="ltr"><<a href="mailto:neil.hodge@gmail.com" target="_blank">neil.hodge@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Jeremy:<div class="im"><br>
<br>
On 11/15/12 7:10 PM, Jeremy Gregorio wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I wanted to start up a new thread on this because I just can't seem to<br>
figure it out. Do I need to set the option at the frame level or can I<br>
instantiate an 'ID3V2.3' object? For reference, I'm trying to keep<br>
compatibility with Win XP (Still running it for games...).<br>
<br>
   Thanks yet again!<br>
<br>
</blockquote>
<br></div>
They seem to have some stuff implemented in TagLib::ID3v2::Header, including:<br>
<br>
* uint majorVersion<br>
* void setMajorVersion<br>
<br>
Although, regarding setMajorVersion, they say "This is used by the internal parser; this will not change the version which is written and in general should not be called by API users."<br>
<br>
I think if you want as much control as you are asking for, you need to implement it yourself.  Check out the function "testDowngradeTo23" in test_id3v2.cpp.<br>
<br>
Good luck . . .<br>
<br>
Neil<br>
<br>
______________________________<u></u>_________________<br>
taglib-devel mailing list<br>
<a href="mailto:taglib-devel@kde.org" target="_blank">taglib-devel@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/taglib-devel" target="_blank">https://mail.kde.org/mailman/<u></u>listinfo/taglib-devel</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Jeremy D Gregorio<br>Sr Consultant<br>#: 520-275-5352<br>fax: 520-747-2540<br><br><a href="http://www.linkedin.com/pub/jeremy-gregorio/36/302/429" target="_blank"><img src="http://www.glimmersoft.com/socialmedia/btn_viewmy_160x33.png"></a><br>
<a href="http://www.glimmersoft.com/socialmedia/btn_viewmy_160x33.png" target="_blank"></a><br>