Package org.farng.mp3

Examples of org.farng.mp3.MP3File


    public void display()
    {
  clear();

  try {
      MP3File m = new MP3File(getFile());
     
      jtAlbum.setText(m.getAlbum());
      jtArtist.setText(m.getArtist());
      jtTitle.setText(m.getTitle());
      jtYear.setText(m.getYear());
      jtComment.setText(m.getComment());

      // why call getFile().canRead()? an IOException should have
      // occured if we could not read the file
      setEnabled(getFile().canWrite());
  }
View Full Code Here


     * Writes id3 tags to file.
     */
    protected void save()
    {
  try {
      MP3File m = new MP3File(getFile());

      m.setTitle(jtTitle.getText());
      m.setArtist(jtArtist.getText());
      m.setAlbum(jtAlbum.getText());
      m.setYear(jtYear.getText());
      m.setComment(jtComment.getText());

      m.writeTags();

      setStatus(XNap.tr("Changes successfully saved."));
  }
  catch (Exception e) {
      setStatus(XNap.tr("Could not write ID Tags to file"));
View Full Code Here

    this.fileName = file.getName();
    File sub = oneUp(file);
    this.subDirectory = sub.getName();
    this.rootDirectory = oneUp(sub).getName();

    MP3File mp3File = new MP3File(file);
    try {
      tag1 = mp3File.getID3V1Tag();
      if(tag1==null){
        tag1 = new ID3V1_0Tag();
      }
    } catch (ID3Exception e) {
      tag1 = new ID3V1_0Tag();
View Full Code Here

    return nullGuard(parameters.get("full"));

  }

  public void persist(String directory) {
    MP3File mp3File = new MP3File(new File(directory + getFull()));
    ID3V1Tag tag1 = null;
    try {
      tag1 = mp3File.getID3V1Tag();
      if(tag1==null){
        tag1 = new ID3V1_0Tag();
      }
    } catch (ID3Exception e) {
      tag1 = new ID3V1_0Tag();
    }
    if(!"".equals(getTitle())) tag1.setTitle(getTitle());
    tag1.setAlbum(getAlbum());
    tag1.setArtist(getArtist());
    tag1.setComment(getComment());
    try {
      tag1.setGenre(Genre.lookupGenre(getGenre()));
    } catch (ID3Exception e) {
    }
    tag1.setYear(getYear());
    mp3File.setID3Tag(tag1);
    try {
      mp3File.sync();
    } catch (ID3Exception e) {
    }
  }
View Full Code Here

   * Construst a SongData from an MP3 at the given absolute path
   * @param path the absolute path of the MP3
   */
  public SongData( String path ) throws SongDataException {
    this.path = tagPrep(path);
    AbstractMP3Tag tag = null;
        try {
      MP3File mp3file = new MP3File(path);
      if (mp3file.hasID3v2Tag()) {
        tag = mp3file.getID3v2Tag();
      } else if (mp3file.hasID3v1Tag()) {
        tag = mp3file.getID3v1Tag();
      } else {
        throw new SongDataException( "No MP3 ID tag found for \""+path+"\"" );
      }
        } catch (TagException tE) {
            throw new SongDataException( "(TagException) Broken MP3 ID tag found for \""+path+"\"" );
        } catch (IOException ioE) {
            log.warn("", ioE);
            throw new SongDataException( "IOE for \""+path+"\"" );
    }

    try { //unfortunately jd3lib isn't perfect...grr...
      title = tagPrep(tag.getSongTitle());
      album = tagPrep(tag.getAlbumTitle());
      artist = tagPrep(tag.getLeadArtist());
            genre = tagPrep(tag.getSongGenre());
            if (genre.length() > 1) { // ensure that genres do not have mutiples because of case
                char firstChar = genre.toUpperCase().charAt(0);
                genre = firstChar+genre.substring(1);
            }
            track = Integer.parseInt(tag.getTrackNumberOnAlbum());

        } catch (NullPointerException npE) {
      throw new SongDataException( "(NPE) Broken MP3 ID tag found for \""+path+"\"" );
    } catch (NumberFormatException nfE) {
            log.warn("No track number for " + title);
View Full Code Here

        // read the 5 character size
        file.read(buffer, 0, 5);
        final int size = Integer.parseInt(new String(buffer, 0, 5));
        if ((size == 0) && (TagOptionSingleton.getInstance().isLyrics3KeepEmptyFieldIfRead() == false)) {
            throw new InvalidTagException("Lyircs3v2 Field has size of zero.");
        }
        buffer = new byte[size];

        // read the SIZE length description
        file.read(buffer);
View Full Code Here

        // read the 5 character size
        file.read(buffer, 0, 5);
        final int size = Integer.parseInt(new String(buffer, 0, 5));
        if ((size == 0) && (TagOptionSingleton.getInstance().isLyrics3KeepEmptyFieldIfRead() == false)) {
            throw new InvalidTagException("Lyircs3v2 Field has size of zero.");
        }
        buffer = new byte[size];

        // read the SIZE length description
        file.read(buffer);
View Full Code Here

        final String identifier = new String(buffer, 0, 4);

        // is this a valid identifier?
        if (isValidID3v2FrameIdentifier(identifier) == false) {
            file.seek(file.getFilePointer() - 3);
            throw new InvalidTagException(identifier + " is not a valid ID3v2.30 frame");
        }
        filePointer = file.getFilePointer();

        // skip the 4 byte size
        file.skipBytes(4);
View Full Code Here

        // read the 5 character size
        file.read(buffer, 0, 5);
        final int size = Integer.parseInt(new String(buffer, 0, 5));
        if ((size == 0) && (TagOptionSingleton.getInstance().isLyrics3KeepEmptyFieldIfRead() == false)) {
            throw new InvalidTagException("Lyircs3v2 Field has size of zero.");
        }
        buffer = new byte[size];

        // read the SIZE length description
        file.read(buffer);
View Full Code Here

        // read the 5 character size
        file.read(buffer, 0, 5);
        final int size = Integer.parseInt(new String(buffer, 0, 5));
        if ((size == 0) && (TagOptionSingleton.getInstance().isLyrics3KeepEmptyFieldIfRead() == false)) {
            throw new InvalidTagException("Lyircs3v2 Field has size of zero.");
        }
        buffer = new byte[size];

        // read the SIZE length description
        file.read(buffer);
View Full Code Here

TOP

Related Classes of org.farng.mp3.MP3File

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.