Examples of Mp3File


Examples of org.farng.mp3.MP3File

    if (isM4A(file)) {
      throw new ID3M4AException(file);
    }

    try {
      MP3File mp3File = new MP3File(file, NOT_WRITEABLE);
      return getID3Tag(mp3File);

    } catch (IOException e) {
      throw new ID3TagFileException(e, file);
    } catch (TagException e) {
View Full Code Here

Examples of org.farng.mp3.MP3File

   *       </ul>
   */
  public static String[] getIDTags(String file) {
    String[] ret = new String[3];
    try {
      MP3File mp3 = new MP3File(file);
      String mtitle = null, martist=null, malbum=null;
      if(mp3.hasID3v1Tag()) {
        mtitle = mp3.getID3v1Tag().getTitle();
        martist = mp3.getID3v1Tag().getArtist();
        malbum = mp3.getID3v1Tag().getAlbum();
      } else if(mp3.hasID3v2Tag()) {
        mtitle = mp3.getID3v2Tag().getSongTitle();
        martist = mp3.getID3v2Tag().getLeadArtist();
        malbum = mp3.getID3v2Tag().getAlbumTitle();
      }
      ret[0] = toUTF8(martist);
      ret[1] = toUTF8(malbum);
      ret[2] = toUTF8(mtitle);
    } catch (Exception e) {
View Full Code Here

Examples of org.jaudiotagger.audio.mp3.MP3File

  @Override
  public void prepare(RawDocument rawDocument) throws RegainException {

    File rawFile = rawDocument.getContentAsFile(false);
    try {
      MP3File mp3file = new MP3File(rawFile);
      ArrayList<String> info = new ArrayList<String>();

      if (mp3file.hasID3v2Tag()) {
        ID3v24Tag id3v24tag = mp3file.getID3v2TagAsv24();

        info.add(id3v24tag.getFirst(ID3v24Frames.FRAME_ID_ARTIST).trim());
        info.add(id3v24tag.getFirst(ID3v24Frames.FRAME_ID_ALBUM).trim());
        info.add(id3v24tag.getFirst(ID3v24Frames.FRAME_ID_TITLE).trim());
        try {
          int year = new Integer(id3v24tag.getFirst(ID3v24Frames.FRAME_ID_YEAR).trim()).intValue();
          if (year > 0) {
            info.add(id3v24tag.getFirst(ID3v24Frames.FRAME_ID_YEAR).trim());
          }
        } catch (Exception ex) {
        }
        info.add(mp3file.getMP3AudioHeader().getTrackLengthAsString().trim());
        info.add(mp3file.getMP3AudioHeader().getBitRate().trim() + "kbps");

        setCleanedContent(concatenateStringParts(info, Integer.MAX_VALUE));
        setTitle(concatenateStringParts(info, 2));

      } else if (mp3file.hasID3v1Tag()) {
        ID3v1Tag tag = mp3file.getID3v1Tag();

        info.add(tag.getFirst(FieldKey.ARTIST).trim());
        info.add(tag.getFirst(FieldKey.ALBUM).trim());
        info.add(tag.getFirst(FieldKey.TITLE).trim());
        try {
          int year = new Integer(tag.getFirst(FieldKey.YEAR).trim()).intValue();
          if (year > 0) {
            info.add(tag.getFirst(FieldKey.YEAR).trim());
          }
        } catch (Exception ex) {
        }
        info.add(mp3file.getMP3AudioHeader().getTrackLengthAsString().trim());
        info.add(mp3file.getMP3AudioHeader().getBitRate().trim() + "kbps");

        setCleanedContent(concatenateStringParts(info, Integer.MAX_VALUE));
        setTitle(concatenateStringParts(info, 2));

      } else {
View Full Code Here

Examples of org.jaudiotagger.audio.mp3.MP3File

    public void parse( final File file ) {

        try {

            MP3File f = (MP3File) AudioFileIO.read( file );
            if ( f.hasID3v2Tag() )
                parseID3v2Tag( f );
            if ( f.hasID3v1Tag() )
                parseID3v1Tag( f );

        } catch ( Exception e ) {
            log.error( "Error parsing MP3 tag: " + e.getMessage() );
        }
View Full Code Here

Examples of org.jaudiotagger.audio.mp3.MP3File

    public Track readSingle(Track track) {
      TrackData trackData = track.getTrackData();
        TextEncoding.getInstanceOf().setDefaultNonUnicode(defaultCharset.name());
        ID3Tag.setDefaultEncoding(defaultCharset.name());
        MP3File mp3File = null;
        try {
            mp3File = new MP3File(trackData.getFile(), MP3File.LOAD_ALL, true);
        } catch (Exception ignored) {
            System.out.println("Couldn't read file: " + trackData.getFile());
        }

        ID3v24Tag v24Tag = null;
        if (mp3File != null) {
            try {
                v24Tag = mp3File.getID3v2TagAsv24();
                if (v24Tag != null) {
                    copyCommonTagFields(v24Tag, track);
                    copySpecificTagFields(v24Tag, track);
                }

                ID3v1Tag id3v1Tag = mp3File.getID3v1Tag();
                if (id3v1Tag != null) {
                    copyCommonTagFields(id3v1Tag, track);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

            MP3AudioHeader mp3AudioHeader = mp3File.getMP3AudioHeader();
            copyHeaderFields(mp3AudioHeader, track);

            long totalSamples = trackData.getTotalSamples();
            int enc_delay = GAPLESS_DELAY;
View Full Code Here

Examples of org.jaudiotagger.audio.mp3.MP3File

                apeTagProcessor.writeAPEv2Tag(track);
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            MP3File mp3File;
            try {
                mp3File = new MP3File(file, MP3File.LOAD_ALL, false);

                ID3v24Tag id3v2tag = mp3File.getID3v2TagAsv24();
                if (id3v2tag == null) {
                    id3v2tag = new ID3v24Tag();
                }
                copyTagFields(id3v2tag, track);

                ID3v11Tag id3v1Tag = new ID3v11Tag(id3v2tag);
                mp3File.setID3v1Tag(id3v1Tag);
                mp3File.setID3v2Tag(id3v2tag);

                mp3File.commit();
            } catch (Exception e) {
                throw new TagWriteException(e);
            }
        }
    }
View Full Code Here

Examples of org.jaudiotagger.audio.mp3.MP3File

            System.err.println("      File " + args[0] + " could not be found");
            System.exit(1);
        }

        try {
            final MP3File tmpMP3 = new MP3File(file);
            tmpMP3.extractID3v2TagDataIntoFile(outFile);
        } catch (Exception e) {
            System.err.println("Unable to extract tag");
            System.exit(1);
        }
    }
View Full Code Here

Examples of xnap.io.MP3File

    sb.append("\"");
    sb.append(NapFileHelper.getShareString(index, file));
    sb.append("\" ");

    if (file instanceof MP3File) {
      MP3File m = (MP3File)file;
      // do not calculate md5, send 0 instead
      sb.append("0 ");
      sb.append(m.length());
      sb.append(" ");
      sb.append(m.getBitrate());
      sb.append(" ");
      sb.append(m.getFrequency());
      sb.append(" ");
      sb.append(m.getPlayingTime());
    }
    else if (file instanceof VideoFile) {
      type = 10300;
      // use new share syntax
      sb.append(file.length());
View Full Code Here

Examples of xnap.io.MP3File

  sb.append("\"");
  sb.append(NapFileHelper.getShareString(index, file));
  sb.append("\" ");
 
  if (file instanceof MP3File) {
      MP3File m = (MP3File)file;
      // do not calculate md5, send 0 instead
      sb.append("0 ");
      sb.append(m.length());
      sb.append(" ");
      sb.append(m.getBitrate());
      sb.append(" ");
      sb.append(m.getFrequency());
      sb.append(" ");
      sb.append(m.getPlayingTime());
  }
  else {
      sb.append("0 ");
      sb.append(file.length());
      sb.append(" 24 16000 600");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.