Package org.farng.mp3.id3

Examples of org.farng.mp3.id3.AbstractID3


        String newAlbumTitle = "New alb title";
        TagOptionSingleton.getInstance().setDefaultSaveMode(TagConstant.MP3_FILE_SAVE_OVERWRITE);
        MP3File mp3file = this.testMusicArray[1];
        ID3v2_4 id3v2 = new ID3v2_4();
        ID3v2_4 filenameId3 = new ID3v2_4();
        ID3v1_1 id3v1 = new ID3v1_1();
        Lyrics3v2 lyrics3 = new Lyrics3v2();
        File renamedFile = new File(this.testMusicDirectory, newAlbumTitle + " - Fat Albert.mp3");
        assertNull(mp3file.getID3v1Tag());
        assertNull(mp3file.getID3v2Tag());
        assertNull(mp3file.getLyrics3Tag());
        assertEquals(0, (mp3file.getFilenameTag().getId3tag()).getFrameCount());

        // setup id3v1
        id3v1.setAlbum(albumTitle);

        // setup id3v2
        AbstractID3v2Frame frame;
        AbstractID3v2FrameBody frameBody;
        frameBody = new FrameBodyTALB((byte) 0, albumTitle);
View Full Code Here


        mp3file.setFrameAcrossTags(frame);
        assertNull(mp3file.getID3v1Tag());
        assertNull(mp3file.getID3v2Tag());
        assertNull(mp3file.getLyrics3Tag());
        assertNull(mp3file.getFilenameTag());
        mp3file.setID3v1Tag(new ID3v1_1());
        mp3file.setID3v2Tag(null);
        mp3file.setLyrics3Tag(null);
        mp3file.setFilenameTag(null);
        mp3file.setFrameAcrossTags(frame);
        mp3file.getID3v1Tag().getAlbum().equals(testString);
        assertNull(mp3file.getID3v2Tag());
        assertNull(mp3file.getLyrics3Tag());
        assertNull(mp3file.getFilenameTag());
        mp3file.setID3v1Tag(null);
        mp3file.setID3v2Tag(new ID3v2_4());
        mp3file.setLyrics3Tag(null);
        mp3file.setFilenameTag(null);
        mp3file.setFrameAcrossTags(frame);
        assertNull(mp3file.getID3v1Tag());
        ((FrameBodyTALB) mp3file.getID3v2Tag().getFrame("TALB").getBody()).getText().equals(testString);
        assertNull(mp3file.getLyrics3Tag());
        assertNull(mp3file.getFilenameTag());
        mp3file.setID3v1Tag(null);
        mp3file.setID3v2Tag(null);
        mp3file.setLyrics3Tag(new Lyrics3v2());
        mp3file.setFilenameTag(null);
        mp3file.setFrameAcrossTags(frame);
        assertNull(mp3file.getID3v1Tag());
        assertNull(mp3file.getID3v2Tag());
        ((FieldBodyEAL) ((Lyrics3v2) mp3file.getLyrics3Tag()).getField("EAL").getBody()).getAlbum().equals(testString);
        assertNull(mp3file.getFilenameTag());
        mp3file.setID3v1Tag(null);
        mp3file.setID3v2Tag(null);
        mp3file.setLyrics3Tag(null);
        mp3file.setFilenameTag(FilenameTagBuilder.createEmptyFilenameTag());
        mp3file.setFrameAcrossTags(frame);
        assertNull(mp3file.getID3v1Tag());
        assertNull(mp3file.getID3v2Tag());
        assertNull(mp3file.getLyrics3Tag());
        ((FrameBodyTALB) mp3file.getFilenameTag().getFrame("TALB").getBody()).getText().equals(testString);
        mp3file.setID3v1Tag(new ID3v1_1());
        mp3file.setID3v2Tag(new ID3v2_4());
        mp3file.setLyrics3Tag(null);
        mp3file.setFilenameTag(null);
        mp3file.setFrameAcrossTags(frame);
        mp3file.getID3v1Tag().getAlbum().equals(testString);
        ((FrameBodyTALB) mp3file.getID3v2Tag().getFrame("TALB").getBody()).getText().equals(testString);
        assertNull(mp3file.getLyrics3Tag());
        assertNull(mp3file.getFilenameTag());
        mp3file.setID3v1Tag(new ID3v1_1());
        mp3file.setID3v2Tag(null);
        mp3file.setLyrics3Tag(new Lyrics3v2());
        mp3file.setFilenameTag(null);
        mp3file.setFrameAcrossTags(frame);
        mp3file.getID3v1Tag().getAlbum().equals(testString);
        assertNull(mp3file.getID3v2Tag());
        ((FieldBodyEAL) ((Lyrics3v2) mp3file.getLyrics3Tag()).getField("EAL").getBody()).getAlbum().equals(testString);
        assertNull(mp3file.getFilenameTag());
        mp3file.setID3v1Tag(new ID3v1_1());
        mp3file.setID3v2Tag(null);
        mp3file.setLyrics3Tag(null);
        mp3file.setFilenameTag(FilenameTagBuilder.createEmptyFilenameTag());
        mp3file.setFrameAcrossTags(frame);
        mp3file.getID3v1Tag().getAlbum().equals(testString);
        assertNull(mp3file.getID3v2Tag());
        assertNull(mp3file.getLyrics3Tag());
        ((FrameBodyTALB) mp3file.getFilenameTag().getFrame("TALB").getBody()).getText().equals(testString);
        mp3file.setID3v1Tag(null);
        mp3file.setID3v2Tag(new ID3v2_4());
        mp3file.setLyrics3Tag(new Lyrics3v2());
        mp3file.setFilenameTag(null);
        mp3file.setFrameAcrossTags(frame);
        assertNull(mp3file.getID3v1Tag());
        ((FrameBodyTALB) mp3file.getID3v2Tag().getFrame("TALB").getBody()).getText().equals(testString);
        ((FieldBodyEAL) ((Lyrics3v2) mp3file.getLyrics3Tag()).getField("EAL").getBody()).getAlbum().equals(testString);
        assertNull(mp3file.getFilenameTag());
        mp3file.setID3v1Tag(null);
        mp3file.setID3v2Tag(new ID3v2_4());
        mp3file.setLyrics3Tag(null);
        mp3file.setFilenameTag(FilenameTagBuilder.createEmptyFilenameTag());
        mp3file.setFrameAcrossTags(frame);
        assertNull(mp3file.getID3v1Tag());
        ((FrameBodyTALB) mp3file.getID3v2Tag().getFrame("TALB").getBody()).getText().equals(testString);
        assertNull(mp3file.getLyrics3Tag());
        ((FrameBodyTALB) mp3file.getFilenameTag().getFrame("TALB").getBody()).getText().equals(testString);
        mp3file.setID3v1Tag(null);
        mp3file.setID3v2Tag(null);
        mp3file.setLyrics3Tag(new Lyrics3v2());
        mp3file.setFilenameTag(FilenameTagBuilder.createEmptyFilenameTag());
        mp3file.setFrameAcrossTags(frame);
        assertNull(mp3file.getID3v1Tag());
        assertNull(mp3file.getID3v2Tag());
        ((FieldBodyEAL) ((Lyrics3v2) mp3file.getLyrics3Tag()).getField("EAL").getBody()).getAlbum().equals(testString);
        ((FrameBodyTALB) mp3file.getFilenameTag().getFrame("TALB").getBody()).getText().equals(testString);
        mp3file.setID3v1Tag(new ID3v1_1());
        mp3file.setID3v2Tag(new ID3v2_4());
        mp3file.setLyrics3Tag(new Lyrics3v2());
        mp3file.setFilenameTag(null);
        mp3file.setFrameAcrossTags(frame);
        mp3file.getID3v1Tag().getAlbum().equals(testString);
        ((FrameBodyTALB) mp3file.getID3v2Tag().getFrame("TALB").getBody()).getText().equals(testString);
        ((FieldBodyEAL) ((Lyrics3v2) mp3file.getLyrics3Tag()).getField("EAL").getBody()).getAlbum().equals(testString);
        assertNull(mp3file.getFilenameTag());
        mp3file.setID3v1Tag(new ID3v1_1());
        mp3file.setID3v2Tag(new ID3v2_4());
        mp3file.setLyrics3Tag(null);
        mp3file.setFilenameTag(FilenameTagBuilder.createEmptyFilenameTag());
        mp3file.setFrameAcrossTags(frame);
        mp3file.getID3v1Tag().getAlbum().equals(testString);
        ((FrameBodyTALB) mp3file.getID3v2Tag().getFrame("TALB").getBody()).getText().equals(testString);
        assertNull(mp3file.getLyrics3Tag());
        ((FrameBodyTALB) mp3file.getFilenameTag().getFrame("TALB").getBody()).getText().equals(testString);
        mp3file.setID3v1Tag(new ID3v1_1());
        mp3file.setID3v2Tag(null);
        mp3file.setLyrics3Tag(new Lyrics3v2());
        mp3file.setFilenameTag(FilenameTagBuilder.createEmptyFilenameTag());
        mp3file.setFrameAcrossTags(frame);
        mp3file.getID3v1Tag().getAlbum().equals(testString);
        assertNull(mp3file.getID3v2Tag());
        ((FieldBodyEAL) ((Lyrics3v2) mp3file.getLyrics3Tag()).getField("EAL").getBody()).getAlbum().equals(testString);
        ((FrameBodyTALB) mp3file.getFilenameTag().getFrame("TALB").getBody()).getText().equals(testString);
        mp3file.setID3v1Tag(null);
        mp3file.setID3v2Tag(new ID3v2_4());
        mp3file.setLyrics3Tag(new Lyrics3v2());
        mp3file.setFilenameTag(FilenameTagBuilder.createEmptyFilenameTag());
        mp3file.setFrameAcrossTags(frame);
        assertNull(mp3file.getID3v1Tag());
        ((FrameBodyTALB) mp3file.getID3v2Tag().getFrame("TALB").getBody()).getText().equals(testString);
        ((FieldBodyEAL) ((Lyrics3v2) mp3file.getLyrics3Tag()).getField("EAL").getBody()).getAlbum().equals(testString);
        ((FrameBodyTALB) mp3file.getFilenameTag().getFrame("TALB").getBody()).getText().equals(testString);

        // test all
        mp3file.setID3v1Tag(new ID3v1_1());
        mp3file.setID3v2Tag(new ID3v2_4());
        mp3file.setLyrics3Tag(new Lyrics3v2());
        mp3file.setFilenameTag(FilenameTagBuilder.createEmptyFilenameTag());
        frameBody = new FrameBodyTIT2();
        ((FrameBodyTIT2) frameBody).setText(testString);
        frame.setBody(frameBody);
        mp3file.setFrameAcrossTags(frame);
        mp3file.getID3v1Tag().getTitle().equals(testString);
        ((FrameBodyTIT2) mp3file.getID3v2Tag().getFrame("TIT2").getBody()).getText().equals(testString);
        ((FieldBodyETT) ((Lyrics3v2) mp3file.getLyrics3Tag()).getField("ETT").getBody()).getTitle().equals(testString);
        ((FrameBodyTIT2) mp3file.getFilenameTag().getFrame("TIT2").getBody()).getText().equals(testString);
        mp3file.setID3v1Tag(new ID3v1_1());
        mp3file.setID3v2Tag(new ID3v2_4());
        mp3file.setLyrics3Tag(new Lyrics3v2());
        mp3file.setFilenameTag(FilenameTagBuilder.createEmptyFilenameTag());
        frameBody = new FrameBodyTPE1();
        ((FrameBodyTPE1) frameBody).setText(testString);
        frame.setBody(frameBody);
        mp3file.setFrameAcrossTags(frame);
        mp3file.getID3v1Tag().getArtist().equals(testString);
        ((FrameBodyTPE1) mp3file.getID3v2Tag().getFrame("TPE1").getBody()).getText().equals(testString);
        ((FieldBodyEAR) ((Lyrics3v2) mp3file.getLyrics3Tag()).getField("EAR").getBody()).getArtist().equals(testString);
        ((FrameBodyTPE1) mp3file.getFilenameTag().getFrame("TPE1").getBody()).getText().equals(testString);
        mp3file.setID3v1Tag(new ID3v1_1());
        mp3file.setID3v2Tag(new ID3v2_4());
        mp3file.setLyrics3Tag(new Lyrics3v2());
        mp3file.setFilenameTag(FilenameTagBuilder.createEmptyFilenameTag());
        frameBody = new FrameBodyTALB();
        ((FrameBodyTALB) frameBody).setText(testString);
        frame.setBody(frameBody);
        mp3file.setFrameAcrossTags(frame);
        mp3file.getID3v1Tag().getAlbum().equals(testString);
        ((FrameBodyTALB) mp3file.getID3v2Tag().getFrame("TALB").getBody()).getText().equals(testString);
        ((FieldBodyEAL) ((Lyrics3v2) mp3file.getLyrics3Tag()).getField("EAL").getBody()).getAlbum().equals(testString);
        ((FrameBodyTALB) mp3file.getFilenameTag().getFrame("TALB").getBody()).getText().equals(testString);
        mp3file.setID3v1Tag(new ID3v1_1());
        mp3file.setID3v2Tag(new ID3v2_4());
        mp3file.setLyrics3Tag(new Lyrics3v2());
        mp3file.setFilenameTag(FilenameTagBuilder.createEmptyFilenameTag());
        frameBody = new FrameBodyTDRC();
        ((FrameBodyTDRC) frameBody).setText("2003");
        frame.setBody(frameBody);
        mp3file.setFrameAcrossTags(frame);
        mp3file.getID3v1Tag().getYear().equals("2003");
        ((FrameBodyTDRC) mp3file.getID3v2Tag().getFrame("TDRC").getBody()).getText().equals("2003");
        assertEquals(0, ((Lyrics3v2) mp3file.getLyrics3Tag()).getFieldCount());
        ((FrameBodyTDRC) mp3file.getFilenameTag().getFrame("TDRC").getBody()).getText().equals("2003");
        mp3file.setID3v1Tag(new ID3v1_1());
        mp3file.setID3v2Tag(new ID3v2_4());
        mp3file.setLyrics3Tag(new Lyrics3v2());
        mp3file.setFilenameTag(FilenameTagBuilder.createEmptyFilenameTag());
        frameBody = new FrameBodyCOMM();
        ((FrameBodyCOMM) frameBody).setText(testString);
        frame.setBody(frameBody);
        mp3file.setFrameAcrossTags(frame);
        mp3file.getID3v1Tag().getComment().equals(testString);
        ((FrameBodyCOMM) ((ID3v2_4Frame) mp3file.getID3v2Tag().getFrameOfType("COMM").next()).getBody()).getText()
                .equals(testString);
        ((FieldBodyINF) ((Lyrics3v2) mp3file.getLyrics3Tag()).getField("INF").getBody()).getAdditionalInformation()
                .equals(testString);
        ((FrameBodyCOMM) ((ID3v2_4Frame) mp3file.getFilenameTag().getFrameOfType("COMM").next()).getBody()).getText()
                .equals(testString);
        mp3file.setID3v1Tag(new ID3v1_1());
        mp3file.setID3v2Tag(new ID3v2_4());
        mp3file.setLyrics3Tag(new Lyrics3v2());
        mp3file.setFilenameTag(FilenameTagBuilder.createEmptyFilenameTag());
        frameBody = new FrameBodyTCON();
        ((FrameBodyTCON) frameBody).setText("42");
        frame.setBody(frameBody);
        mp3file.setFrameAcrossTags(frame);
        assertEquals(42, mp3file.getID3v1Tag().getGenre());
        ((FrameBodyTCON) mp3file.getID3v2Tag().getFrame("TCON").getBody()).getText().equals("42");
        assertEquals(0, ((Lyrics3v2) mp3file.getLyrics3Tag()).getFieldCount());
        ((FrameBodyTCON) mp3file.getFilenameTag().getFrame("TCON").getBody()).getText().equals("42");
        mp3file.setID3v1Tag(new ID3v1_1());
        mp3file.setID3v2Tag(new ID3v2_4());
        mp3file.setLyrics3Tag(new Lyrics3v2());
        mp3file.setFilenameTag(FilenameTagBuilder.createEmptyFilenameTag());
        frameBody = new FrameBodyTRCK();
        ((FrameBodyTRCK) frameBody).setText("42");
        frame.setBody(frameBody);
        mp3file.setFrameAcrossTags(frame);
        assertEquals(42, ((ID3v1_1) mp3file.getID3v1Tag()).getTrack());
        ((FrameBodyTRCK) mp3file.getID3v2Tag().getFrame("TRCK").getBody()).getText().equals("42");
        assertEquals(0, ((Lyrics3v2) mp3file.getLyrics3Tag()).getFieldCount());
        ((FrameBodyTRCK) mp3file.getFilenameTag().getFrame("TRCK").getBody()).getText().equals("42");
        mp3file.setID3v1Tag(new ID3v1_1());
        mp3file.setID3v2Tag(new ID3v2_4());
        mp3file.setLyrics3Tag(new Lyrics3v2());
        mp3file.setFilenameTag(FilenameTagBuilder.createEmptyFilenameTag());
        frameBody = new FrameBodySYLT();
        ((FrameBodySYLT) frameBody).addLyric(0, testString);
        frame.setBody(frameBody);
        mp3file.setFrameAcrossTags(frame);
        assertEquals(0, (new ID3v2_4(mp3file.getID3v1Tag())).getFrameCount());
        ((FrameBodySYLT) mp3file.getID3v2Tag().getFrame("SYLT").getBody()).getLyric().equals(testString);
        ((FieldBodyLYR) ((Lyrics3v2) mp3file.getLyrics3Tag()).getField("LYR").getBody()).getLyric().equals(testString);
        ((FrameBodySYLT) mp3file.getFilenameTag().getFrame("SYLT").getBody()).getLyric().equals(testString);
        mp3file.setID3v1Tag(new ID3v1_1());
        mp3file.setID3v2Tag(new ID3v2_4());
        mp3file.setLyrics3Tag(new Lyrics3v2());
        mp3file.setFilenameTag(FilenameTagBuilder.createEmptyFilenameTag());
        frameBody = new FrameBodyUSLT();
        ((FrameBodyUSLT) frameBody).setLyric(testString);
        frame.setBody(frameBody);
        mp3file.setFrameAcrossTags(frame);
        assertEquals(0, (new ID3v2_4(mp3file.getID3v1Tag())).getFrameCount());
        ((FrameBodyUSLT) ((ID3v2_4Frame) mp3file.getID3v2Tag().getFrameOfType("USLT").next()).getBody()).getLyric()
                .equals(testString);
        ((FieldBodyLYR) ((Lyrics3v2) mp3file.getLyrics3Tag()).getField("LYR").getBody()).getLyric().equals(testString);
        ((FrameBodyUSLT) ((ID3v2_4Frame) mp3file.getFilenameTag().getFrameOfType("USLT").next()).getBody()).getLyric()
                .equals(testString);
        mp3file.setID3v1Tag(new ID3v1_1());
        mp3file.setID3v2Tag(new ID3v2_4());
        mp3file.setLyrics3Tag(new Lyrics3v2());
        mp3file.setFilenameTag(FilenameTagBuilder.createEmptyFilenameTag());
        frameBody = new FrameBodyTCOM();
        ((FrameBodyTCOM) frameBody).setText(testString);
View Full Code Here

    public MP3File(final File file, final boolean writeable) throws IOException, TagException {
        super();
        mp3file = file;
        final RandomAccessFile newFile = new RandomAccessFile(file, writeable ? "rw" : "r");
        try {
            id3v1tag = new ID3v1_1(newFile);
        } catch (TagNotFoundException ex) {
            // tag might be different version
        }
        try {
            if (id3v1tag == null) {
View Full Code Here

     * and then used here.
     *
     * @param mp3tag Any MP3Tag object can be used and will be converted into a new ID3v1_1 object.
     */
    public void setID3v1Tag(final AbstractMP3Tag mp3tag) {
        id3v1tag = new ID3v1_1(mp3tag);
    }
View Full Code Here

        } catch (TagNotFoundException ex) {
            // maybe a different version
        }
        try {
            if (id3v2tag == null) {
                id3v2tag = new ID3v2_2(newFile);
            }
        } catch (TagNotFoundException ex) {
            // it's ok to be null
        }
        try {
View Full Code Here

        } catch (TagNotFoundException ex) {
            // maybe different version
        }
        try {
            if (id3v2tag == null) {
                id3v2tag = new ID3v2_3(newFile);
            }
        } catch (TagNotFoundException ex) {
            // maybe a different version
        }
        try {
View Full Code Here

    }

    public void setSongTitle(String songTitle) {
        AbstractID3v2Frame field = getFrame("TIT2");
        if (field == null) {
            field = new ID3v2_3Frame(new FrameBodyTIT2((byte) 0, songTitle.trim()));
            setFrame(field);
        } else {
            ((FrameBodyTIT2) field.getBody()).setText(songTitle.trim());
        }
    }
View Full Code Here

    }

    public void setLeadArtist(String leadArtist) {
        AbstractID3v2Frame field = getFrame("TPE1");
        if (field == null) {
            field = new ID3v2_3Frame(new FrameBodyTPE1((byte) 0, leadArtist.trim()));
            setFrame(field);
        } else {
            ((FrameBodyTPE1) field.getBody()).setText(leadArtist.trim());
        }
    }
View Full Code Here

    }

    public void setAlbumTitle(String albumTitle) {
        AbstractID3v2Frame field = getFrame("TALB");
        if (field == null) {
            field = new ID3v2_3Frame(new FrameBodyTALB((byte) 0, albumTitle.trim()));
            setFrame(field);
        } else {
            ((FrameBodyTALB) field.getBody()).setText(albumTitle.trim());
        }
    }
View Full Code Here

    }

    public void setYearReleased(String yearReleased) {
        AbstractID3v2Frame field = getFrame("TDRC");
        if (field == null) {
            field = new ID3v2_3Frame(new FrameBodyTDRC((byte) 0, yearReleased.trim()));
            setFrame(field);
        } else {
            ((FrameBodyTDRC) field.getBody()).setText(yearReleased.trim());
        }
    }
View Full Code Here

TOP

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

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.