Package com.mpatric.mp3agic

Examples of com.mpatric.mp3agic.Mp3File


  private Logger logger = LoggerFactory.getLogger(MP3FileExtractor.class);
 
  @Override
  protected void performExtraction(URI arg0, File arg1, Charset arg2, String arg3, RDFContainer result) throws ExtractorException {
    try {
      Mp3File mp3File = new Mp3File(arg1.toString());
      ID3v1 id3v1 = mp3File.getId3v1Tag();
      ID3v2 id3v2 = mp3File.getId3v2Tag();
      ID3Wrapper wrapper = new ID3Wrapper(id3v1,id3v2);
      addId3Fields(wrapper,result);
      result.add(RDF.type, NID3.ID3Audio);
     
    } catch (UnsupportedTagException e) {
View Full Code Here


                    is.close();
                }
            }

            // Remove id3v1 tag
            Mp3File mp3File = new Mp3File(tempFile.getAbsolutePath());
            if (mp3File.hasId3v1Tag()) {
                mp3File.removeId3v1Tag();
            }

            // Get/create id3v2 tag
            ID3v2 id3v2Tag;
            if (mp3File.hasId3v2Tag()) {
                id3v2Tag = mp3File.getId3v2Tag();
            } else {
                id3v2Tag = new ID3v23Tag();
            }
            Exception err = null;
            while (true) {
                // Try saving twice; once with old tag data, and again after
                // discarding corrupt data and starting over
                try {
                    id3v2Tag.setTitle(song.getName());
                    id3v2Tag.setArtist(song.getArtistName());
                    id3v2Tag.setAlbum(song.getAlbumName());
                    id3v2Tag.setYear(song.getYear() + "");
                    Utils.encodeId(song.getId(), id3v2Tag);
                    mp3File.setId3v2Tag(id3v2Tag);
                    mp3File.save(tempFile2.getAbsolutePath());
                    break;
                } catch (NotSupportedException e) {
                    if (err != null) {
                        e.initCause(err);
                        throw e;
View Full Code Here

     * Find the song ID associated with a file.
     *
     * @return The song ID, or {@link #ID_NONE}.
     */
    public static int decodeId(File file) {
        Mp3File mp3File;
        try {
            mp3File = new Mp3File(file.getAbsolutePath());
            if (mp3File.hasId3v2Tag()) {
                String encoder = mp3File.getId3v2Tag().getEncoder();
                if (encoder != null) {
                    Matcher matcher = ID_PATTERN.matcher(encoder);
                    if (matcher.matches()) {
                        return Integer.parseInt(matcher.group(1));
                    }
View Full Code Here

                    is.close();
                }
            }

            // Remove id3v1 tag
            Mp3File mp3File = new Mp3File(tempFile.getAbsolutePath());
            if (mp3File.hasId3v1Tag()) {
                mp3File.removeId3v1Tag();
            }

            // Get/create id3v2 tag
            ID3v2 id3v2Tag;
            if (mp3File.hasId3v2Tag()) {
                id3v2Tag = mp3File.getId3v2Tag();
            } else {
                id3v2Tag = new ID3v23Tag();
            }
            Exception err = null;
            while (true) {
                // Try saving twice; once with old tag data, and again after
                // discarding corrupt data and starting over
                try {
                    id3v2Tag.setTitle(song.getName());
                    id3v2Tag.setArtist(song.getArtistName());
                    id3v2Tag.setAlbum(song.getAlbumName());
                    id3v2Tag.setYear(song.getYear() + "");
                    Utils.encodeId(song.getId(), id3v2Tag);
                    mp3File.setId3v2Tag(id3v2Tag);
                    mp3File.save(tempFile2.getAbsolutePath());
                    break;
                } catch (NotSupportedException e) {
                    if (err != null) {
                        e.initCause(err);
                        throw e;
View Full Code Here

TOP

Related Classes of com.mpatric.mp3agic.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.