Package org.farng.mp3.id3

Examples of org.farng.mp3.id3.ID3v1


    }
    return parse;
  }

  private Parse getID3v1Parse(MP3File mp3) throws MalformedURLException {
    ID3v1 tag = mp3.getID3v1Tag();
    metadataCollector.notifyProperty("TALB-Text", tag.getAlbum());
    metadataCollector.notifyProperty("TPE1-Text", tag.getArtist());
    metadataCollector.notifyProperty("COMM-Text", tag.getComment());
    metadataCollector.notifyProperty("TCON-Text", "(" + tag.getGenre() + ")");
    metadataCollector.notifyProperty("TIT2-Text", tag.getTitle());
    metadataCollector.notifyProperty("TYER-Text", tag.getYear());
    ParseData parseData = new ParseData(metadataCollector.getTitle(),
        metadataCollector.getOutlinks(),
        metadataCollector.getData());
    return new ParseImpl(metadataCollector.getText(), parseData);
  }
View Full Code Here


    }
    return parse;
  }

  private Parse getID3v1Parse(MP3File mp3) throws MalformedURLException {
    ID3v1 tag = mp3.getID3v1Tag();
    metadataCollector.notifyProperty("TALB-Text", tag.getAlbum());
    metadataCollector.notifyProperty("TPE1-Text", tag.getArtist());
    metadataCollector.notifyProperty("COMM-Text", tag.getComment());
    metadataCollector.notifyProperty("TCON-Text", "(" + tag.getGenre() + ")");
    metadataCollector.notifyProperty("TIT2-Text", tag.getTitle());
    metadataCollector.notifyProperty("TYER-Text", tag.getYear());
    ParseData parseData = new ParseData(metadataCollector.getTitle(),
        metadataCollector.getOutlinks(),
        metadataCollector.getData());
    return new ParseImpl(metadataCollector.getText(), parseData);
  }
View Full Code Here

  }

  private ParseResult getID3v1Parse(MP3File mp3, Metadata contentMeta,
      Content content) throws MalformedURLException {

    ID3v1 tag = mp3.getID3v1Tag();
    metadataCollector.notifyProperty("TALB-Text", tag.getAlbum());
    metadataCollector.notifyProperty("TPE1-Text", tag.getArtist());
    metadataCollector.notifyProperty("COMM-Text", tag.getComment());
    metadataCollector.notifyProperty("TCON-Text", "(" + tag.getGenre()
        + ")");
    metadataCollector.notifyProperty("TIT2-Text", tag.getTitle());
    metadataCollector.notifyProperty("TYER-Text", tag.getYear());
    ParseData parseData = new ParseData(ParseStatus.STATUS_SUCCESS,
        metadataCollector.getTitle(), metadataCollector.getOutlinks(),
        contentMeta, metadataCollector.getData());
    ParseResult parseResult = ParseResult.createParseResult(content
        .getUrl(),
View Full Code Here

  }

  private Parse getID3v1Parse(MP3File mp3, Metadata contentMeta)
  throws MalformedURLException {

    ID3v1 tag = mp3.getID3v1Tag();
    metadataCollector.notifyProperty("TALB-Text", tag.getAlbum());
    metadataCollector.notifyProperty("TPE1-Text", tag.getArtist());
    metadataCollector.notifyProperty("COMM-Text", tag.getComment());
    metadataCollector.notifyProperty("TCON-Text", "(" + tag.getGenre() + ")");
    metadataCollector.notifyProperty("TIT2-Text", tag.getTitle());
    metadataCollector.notifyProperty("TYER-Text", tag.getYear());
    ParseData parseData = new ParseData(ParseStatus.STATUS_SUCCESS,
                                        metadataCollector.getTitle(),
                                        metadataCollector.getOutlinks(),
                                        contentMeta,
                                        metadataCollector.getData());
View Full Code Here

        } catch (TagNotFoundException ex) {
            // tag might be different version
        }
        try {
            if (id3v1tag == null) {
                id3v1tag = new ID3v1(newFile);
            }
        } catch (TagNotFoundException ex) {
            // ok if it's null
        }
        try {
View Full Code Here

                }
            }
            if (TagOptionSingleton.getInstance().isId3v1Save()) {
                if (id3v1tag == null) {
                    if (saveMode == TagConstant.MP3_FILE_SAVE_OVERWRITE) {
                        (new ID3v1()).delete(rfile);
                    }
                } else {
                    if (saveMode == TagConstant.MP3_FILE_SAVE_WRITE) {
                        id3v1tag.write(rfile);
                    } else if (saveMode == TagConstant.MP3_FILE_SAVE_APPEND) {
View Full Code Here

        }
    }

    public void delete(final RandomAccessFile file) throws IOException {
        long filePointer;
        ID3v1 id3v1tag = new ID3v1();
        if (seek(file)) {
            id3v1tag = id3v1tag.getID3tag(file);
            seek(file);
            filePointer = file.getFilePointer();

            // cut off the "LYRICSBEGIN"
            filePointer -= 11;
            file.setLength(filePointer);
            file.seek(file.length());
            if (id3v1tag != null) {
                id3v1tag.write(file);
            }
        }
    }
View Full Code Here

    public void write(final RandomAccessFile file) throws IOException {
        String str;
        int offset;
        final byte[] buffer;
        final ID3v1 id3v1tag;
        id3v1tag = (new ID3v1()).getID3tag(file);
        delete(file);
        file.seek(file.length());
        buffer = new byte[this.lyric.length() + 11 + 9];
        str = "LYRICSBEGIN";
        for (int i = 0; i < str.length(); i++) {
            buffer[i] = (byte) str.charAt(i);
        }
        offset = str.length();
        str = TagUtility.truncate(this.lyric, 5100);
        for (int i = 0; i < str.length(); i++) {
            buffer[i + offset] = (byte) str.charAt(i);
        }
        offset += str.length();
        str = "LYRICSEND";
        for (int i = 0; i < str.length(); i++) {
            buffer[i + offset] = (byte) str.charAt(i);
        }
        offset += str.length();
        file.write(buffer, 0, offset);
        if (id3v1tag != null) {
            id3v1tag.write(file);
        }
    }
View Full Code Here

        final long filePointer;
        final byte[] buffer = new byte[6 + 9];
        String str;
        Lyrics3v2Field field;
        final Iterator iterator;
        ID3v1 id3v1tag = new ID3v1();
        id3v1tag = id3v1tag.getID3tag(file);
        delete(file);
        file.seek(file.length());
        filePointer = file.getFilePointer();
        str = "LYRICSBEGIN";
        for (int i = 0; i < str.length(); i++) {
            buffer[i] = (byte) str.charAt(i);
        }
        file.write(buffer, 0, str.length());

        // IND needs to go first. lets create/update it and write it first.
        updateField("IND");
        field = (Lyrics3v2Field) this.fieldMap.get("IND");
        field.write(file);
        iterator = this.fieldMap.values().iterator();
        while (iterator.hasNext()) {
            field = (Lyrics3v2Field) iterator.next();
            final String id = field.getIdentifier();
            final boolean save = TagOptionSingleton.getInstance().getLyrics3SaveField(id);
            if ((id.equals("IND") == false) && save) {
                field.write(file);
            }
        }
        final long size;
        size = file.getFilePointer() - filePointer;
        str = Long.toString(size);
        for (int i = 0; i < (6 - str.length()); i++) {
            buffer[i] = (byte) '0';
        }
        offset += (6 - str.length());
        for (int i = 0; i < str.length(); i++) {
            buffer[i + offset] = (byte) str.charAt(i);
        }
        offset += str.length();
        str = "LYRICS200";
        for (int i = 0; i < str.length(); i++) {
            buffer[i + offset] = (byte) str.charAt(i);
        }
        offset += str.length();
        file.write(buffer, 0, offset);
        if (id3v1tag != null) {
            id3v1tag.write(file);
        }
    }
View Full Code Here

  public void ID3v2GenreTestWithID() throws ID3TagFileException{
    this.testID3v2Genre("(13)", "Pop");
  }

  private void testID3v1Genre(String input, String expectedOutput) throws ID3TagFileException {
    ID3v1 id3Mock = EasyMock.createMock(ID3v1.class);
    MP3File mp3FileMock = TagTestHelpLibrary.createMP3FileMockForID3v1(id3Mock);

    EasyMock.expect(id3Mock.getSongGenre()).andReturn(input);
    EasyMock.replay(id3Mock, mp3FileMock);

    ID3Tag tag = jidID3TagFactory.getID3Tag(mp3FileMock);
    assertEquals(expectedOutput, tag.getGenreAsString());
View Full Code Here

TOP

Related Classes of org.farng.mp3.id3.ID3v1

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.