1
Vote

Cannot write both ID3v1.x and ID3v2.x tags to the same file

description

The overload of Mp3Stream.WriteTag that takes a majorVersion and minorVersion should allow a developer to write the same tag to single stream using both v1.x and v2.x handlers. Unfortunately, the current code deletes the first tag from the stream when the second tag is written. The tag deletion is meant to prevent duplicate tags within the same family, which is good.

The bug lies in the overload of WriteTag that updates tag.MajorVersion and tag.MinorVersion--it should also update tag.Family so that subsequent code only deletes tags within the same family:
    public bool WriteTag(Id3Tag tag, int majorVersion, int minorVersion,
        WriteConflictAction conflictAction = WriteConflictAction.NoAction)
    {
        tag.MajorVersion = majorVersion;
        tag.MinorVersion = minorVersion;

        // TODO: Need to update tag.Family to match tag.MajorVersion here.

        return WriteTag(tag, conflictAction);
    }

comments