<div dir="ltr"><div><div><div><div><div><div>Hi Jarno,<br><br></div>my application writes common tags like this:<br><br>bool MediaFile::WriteTags()<br>{<br>    TagLib::FileRef fileref(filename);<br><br>    if(!fileref.isNull())<br>
    {<br>        TagLib::Tag *tag = fileref.tag();<br>        if(tag)<br>        {<br>            tag->setTitle(TagLib::String(tagData->Title()));<br>            tag->setArtist(TagLib::String(tagData->Artist()));<br>
            tag->setAlbum(TagLib::String(tagData->Album()));<br>            tag->setComment(TagLib::String(tagData->Comment()));<br>            tag->setGenre(TagLib::String(tagData->Genre()));<br>            tag->setYear(tagData->Year());<br>
            tag->setTrack(tagData->Track());<br>        }<br>        else<br>        {<br>            return false;<br>        }<br>        return fileref.save();<br>    }<br>    return false;<br>}<br><br></div>This works for every supported audio file format. As long as you don't want to add format specific metadata (like cover pictures for instance), you don't have to worry about property maps, frames etc.<br>
</div>I cannot reproduce the case that fileref.tag() returns a NULL pointer.<br></div>Even if my file is a text file with mp3 extension and not an actual audio file, the method works and metadata information is written to the file.<br>
<br></div>Cheers,<br></div>Thomas<br><div><div><div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Apr 4, 2014 at 9:58 AM, Jarno Lavikonmäki <span dir="ltr"><<a href="mailto:lavikonm@gmail.com" target="_blank">lavikonm@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div> </div><div>Hi, </div><div><br></div><div>some part of this tag lib that I do not yet understand </div>
<div><br></div><div>the case here is to update metadata to file </div><div><br></div><div>first , if I try </div>
<div><br></div><div> TagLib::FileRef f("mytestmp3.mp3");<br></div><div><br></div><div>then f.tag() returns NULL; </div><div><br></div><div>then I do it this way: </div><div><br></div><div> TagLib::MPEG::File mp3File("mytestmp3.mp3");</div>

<div><br></div><div>first round, this mp3 files does not have ID3v2 or ID3v1 </div><div><br></div><div>so it goes to "else" branch and calls to to  create ID3v2Tag(true)</div><div><br></div><div>and then calls </div>

<div><br></div><div>mp3Tagv2->setArtist("setArtistField");<br></div><div><br></div><div>and after that </div><div>bool result = mp3File.save();<br></div><div><br></div><div>..</div><div><br></div><div>then next round .. </div>

<div><br></div><div>hasID3v2Tag() returns true <br></div><div><br></div><div>but actual file in file system does not have metadata updated ,</div><div><br></div><div>so what is the "documented" way , to use propertymaps or something else ? </div>

<div><br></div><div>Thanks in advance </div><div><br></div><div>br. Jarno </div></div>
<br>_______________________________________________<br>
taglib-devel mailing list<br>
<a href="mailto:taglib-devel@kde.org">taglib-devel@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/taglib-devel" target="_blank">https://mail.kde.org/mailman/listinfo/taglib-devel</a><br>
<br></blockquote></div><br></div></div></div></div></div></div></div>