Package org.cmc.music.metadata

Examples of org.cmc.music.metadata.IMusicMetadata


  }

  public IMusicMetadata parseTags(MyID3Listener listener, byte bytes[],
      boolean strict)
  {
    IMusicMetadata result = new MusicMetadata("ID3v1");

    int counter = 3;
    String title = getField(listener, bytes, counter, 30);
    counter += 30;
    result.setSongTitle(title);
    if (null != listener)
      listener.logWithLength("id3v1 title", title);

    String artist = getField(listener, bytes, counter, 30);
    counter += 30;
    result.setArtist(artist);
    if (null != listener)
      listener.logWithLength("id3v1 artist", artist);

    String album = getField(listener, bytes, counter, 30);
    counter += 30;
    result.setAlbum(album);
    if (null != listener)
      listener.logWithLength("id3v1 album", album);

    String yearString = getField(listener, bytes, counter, 4);
    counter += 4;
    Number year = null;
    try
    {
      if (null != yearString)
        year = Integer.valueOf(yearString);
    } catch (NumberFormatException e)
    {
      // ignore
    }
    result.setYear(year);
    if (null != listener)
    {
      listener.logWithLength("id3v1 year", yearString);
      if (null != yearString)
        listener.log("id3v1 year", year);
    }

    String comment = getField(listener, bytes, counter, 30);
    counter += 30;
    if (null != comment)
      result.addComment(comment);
    if (null != listener)
      listener.logWithLength("id3v1 comment", comment);

    if (bytes[counter - 2] == 0 && bytes[counter - 1] != 0)
    {
      int trackNumber = 0xff & bytes[counter - 1];
      // TODO: should we ignore 0x00 and 0xff track numbers?
      result.setTrackNumberNumeric(new Integer(trackNumber));

      if (null != listener)
        listener.log("id3v1 trackNumber: " + trackNumber);
    }

    int genre = 0xff & bytes[counter];
    if (genre < 80 && genre > 0)
    {
      result.setGenreID(new Integer(genre));
      result.setGenreName(ID3v1Genre.getNameForID(new Integer(genre)));

      if (null != listener)
        listener.log("id3v1 genre: " + genre);
    }
View Full Code Here


      return null;

    if (null != listener)
      listener.log("ID3v1 tag found.");

    IMusicMetadata tags = new MyID3v1().parseTags(listener, bytes, strict);

    return new ID3Tag.V1(bytes, tags);
  }
View Full Code Here

    return rectifier.rectifySongTitle(s);
  }

  public IMusicMetadata process(IMusicMetadata src)
  {
    IMusicMetadata result = new MusicMetadata(src.getMetadataName()
        + " clean", src);

    {
      String s = src.getArtist();
      // Debug.debug("before", s);
      s = processArtist(s);
      // Debug.debug("after", s);
      result.setArtist(s);
    }
    {
      String s = src.getAlbum();
      // Debug.debug("before album", s);
      s = processAlbum(s);
      // Debug.debug("after album", s);
      result.setAlbum(s);
    }
    {
      String s = src.getSongTitle();
      // Debug.debug("before", s);
      s = processSongTitle(s);
      // Debug.debug("after", s);
      result.setSongTitle(s);
    }

    return result;
  }
View Full Code Here

        return true;
      }
    };

    IMusicMetadata metadata = srcSet.merged;
    new MyID3().write(mp3File, temp, srcSet, metadata, filter, listener);

    MusicMetadataSet temp_set = new MyID3().read(temp, listener);
  }
View Full Code Here

  {
    // Since this is an example, I do no checking of parameters.

    MusicMetadataSet src_set = new MyID3().read(srcFile);

    IMusicMetadata metadataToWrite;
    if (src_set != null)
    {
      // The source file DID have an ID3v1 or ID3v2 tag (or both).
      // We'll update those values.
      metadataToWrite = src_set.merged;
    } else
    {
      // The file did not have an ID3v1 or ID3v2 tag, so
      // we need to add new tag(s).
      metadataToWrite = MusicMetadata.createEmptyMetadata();
    }

    // here we set or update the artist field.
    metadataToWrite.setArtist(artist);

    new MyID3().write(srcFile, dstFile, src_set, metadataToWrite);
  }
View Full Code Here

    Vector frames = parser.getTags();

    // Debug.debug("tags" , tags.toString());

    IMusicMetadata metadata = ID3v2FrameTranslation
        .translateFramesToMetadata(listener, strict, frames);

    // IMusicMetadata values = ID3v2DataMapping.translateFrames(listener,
    // strict, tags);
View Full Code Here

  public HashMap<String, String> parseFile(String Media, String FilePath) {
   
    File File = new File(FilePath);
   
    try {
      IMusicMetadata Tags = new MyID3().read(File).getSimplified();
     
      ParsedData.put("title", Tags.getSongTitle());
      ParsedData.put("artist", Tags.getArtist());
     
    } catch (Exception e) {}
   
    return ParsedData;
  }
View Full Code Here

TOP

Related Classes of org.cmc.music.metadata.IMusicMetadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.