[Schmitzm-commits] r2368 - in trunk/schmitzm-mp3/src/main/java/de/schmitzm/mp3/id3: . gui

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Mon Jul 22 17:08:44 CEST 2013


Author: mojays
Date: 2013-07-22 17:08:44 +0200 (Mon, 22 Jul 2013)
New Revision: 2368

Modified:
   trunk/schmitzm-mp3/src/main/java/de/schmitzm/mp3/id3/ID3TagUtil.java
   trunk/schmitzm-mp3/src/main/java/de/schmitzm/mp3/id3/ID3V1_1aTag.java
   trunk/schmitzm-mp3/src/main/java/de/schmitzm/mp3/id3/gui/ID3TagV1Panel.java
Log:
BugFix: when ID3v1 genre was set to NULL, it was set to 0 ("Blues")

Modified: trunk/schmitzm-mp3/src/main/java/de/schmitzm/mp3/id3/ID3TagUtil.java
===================================================================
--- trunk/schmitzm-mp3/src/main/java/de/schmitzm/mp3/id3/ID3TagUtil.java	2013-07-19 16:11:30 UTC (rev 2367)
+++ trunk/schmitzm-mp3/src/main/java/de/schmitzm/mp3/id3/ID3TagUtil.java	2013-07-22 15:08:44 UTC (rev 2368)
@@ -624,6 +624,20 @@
   }
 
   /**
+   * Sets the genre of an ID3 v1 tag. If {@code null} value is given, the
+   * genre is set to {@link Genre#Undefined}, because otherwise NULL genre is stored
+   * as byte value 0 in tag (see {@link ID3V1_1Tag#write(java.io.OutputStream)}) which
+   * represents "Blues"! 
+   * @param tag tag to modify
+   * @param value new genre value
+   */
+  public static void setGenre(ID3V1Tag tag, Genre genre) {
+    if ( genre == null )
+      genre = Genre.Undefined;
+    tag.setGenre(genre);
+  }
+
+  /**
    * Sets the genre of an ID3 v2 tag. If {@code null} value is given, the
    * header is removed from tag.
    * @param tag tag to modify
@@ -716,7 +730,7 @@
                         break;
       case GENRE: if ( tag instanceof ID3V1Tag ) {
                     Genre genre = value != null ? Genre.lookupGenre(value) : null;
-                    ((ID3V1Tag)tag).setGenre(genre);
+                    setGenre((ID3V1Tag)tag,genre);
                   }
                   if ( tag instanceof ID3V2Tag )
                     setGenre((ID3V2Tag)tag, value);
@@ -771,7 +785,7 @@
     newTag.setAlbum( tag.getAlbum() );
     newTag.setArtist( tag.getArtist() );
     newTag.setComment( tag.getComment() );
-    newTag.setGenre( tag.getGenre() );
+    ID3TagUtil.setGenre(newTag, tag.getGenre() );
     newTag.setTitle( tag.getTitle() );
     newTag.setYear( tag.getYear() );
     if ( tag instanceof ID3V1_1Tag )
@@ -790,7 +804,7 @@
     newTag.setAlbum( StringUtils.trimToEmpty(tag.getAlbum()) );
     newTag.setArtist( StringUtils.trimToEmpty(tag.getArtist()) );
     newTag.setComment( StringUtils.trimToEmpty(tag.getComment()) );
-    newTag.setGenre( getGenreName(tag) == null ? null : Genre.lookupGenre( getGenreName(tag)) );
+    ID3TagUtil.setGenre(newTag, getGenreName(tag) == null ? null : Genre.lookupGenre( getGenreName(tag)) );
     newTag.setTitle( StringUtils.trimToEmpty(tag.getTitle()) );
     Integer year = getYear(tag);
     newTag.setYear( year == null ? "" : year.toString() );

Modified: trunk/schmitzm-mp3/src/main/java/de/schmitzm/mp3/id3/ID3V1_1aTag.java
===================================================================
--- trunk/schmitzm-mp3/src/main/java/de/schmitzm/mp3/id3/ID3V1_1aTag.java	2013-07-19 16:11:30 UTC (rev 2367)
+++ trunk/schmitzm-mp3/src/main/java/de/schmitzm/mp3/id3/ID3V1_1aTag.java	2013-07-22 15:08:44 UTC (rev 2368)
@@ -61,7 +61,7 @@
       setTitle( tag.getTitle() );
       setArtist( tag.getArtist() );
       setAlbum( tag.getAlbum() );
-      setGenre( tag.getGenre() );
+      ID3TagUtil.setGenre(this, tag.getGenre());
       setYear( tag.getYear() );
       if ( tag instanceof org.blinkenlights.jid3.v1.ID3V1_1Tag )
         try {

Modified: trunk/schmitzm-mp3/src/main/java/de/schmitzm/mp3/id3/gui/ID3TagV1Panel.java
===================================================================
--- trunk/schmitzm-mp3/src/main/java/de/schmitzm/mp3/id3/gui/ID3TagV1Panel.java	2013-07-19 16:11:30 UTC (rev 2367)
+++ trunk/schmitzm-mp3/src/main/java/de/schmitzm/mp3/id3/gui/ID3TagV1Panel.java	2013-07-22 15:08:44 UTC (rev 2368)
@@ -35,6 +35,7 @@
 import org.blinkenlights.jid3.v1.ID3V1Tag.Genre;
 import org.blinkenlights.jid3.v1.ID3V1_1Tag;
 
+import de.schmitzm.mp3.id3.ID3TagField;
 import de.schmitzm.mp3.id3.ID3TagUtil;
 import de.schmitzm.swing.LimitedDocument;
 
@@ -113,7 +114,7 @@
     if ( yearCheckbox.getValue() )
       tag.setYear( year.getValue() == null ? null : year.getValue().toString() );
     if ( genreCheckbox.getValue() )
-      tag.setGenre( (Genre)genre.getValue() );
+      ID3TagUtil.setGenre(tag, (Genre)genre.getValue());
     if ( commentCheckbox.getValue() )
       tag.setComment( StringUtils.trimToEmpty(comment.getValue()) );
     if ( trackNoCheckbox.getValue() && tag instanceof ID3V1_1Tag ) {
@@ -151,7 +152,7 @@
     if ( yearCheckbox.getValue() )
       tag2.setYear( tag1.getYear() );
     if ( genreCheckbox.getValue() )
-      tag2.setGenre( tag1.getGenre() );
+      ID3TagUtil.setGenre( tag2, tag1.getGenre() );
     if ( commentCheckbox.getValue() )
       tag2.setComment( tag1.getComment() );
     if ( trackNoCheckbox.getValue() && tag1 instanceof ID3V1_1Tag  && tag2 instanceof ID3V1_1Tag )



More information about the Schmitzm-commits mailing list