Package org.farng.mp3.lyrics3

Examples of org.farng.mp3.lyrics3.Lyrics3v1Iterator


     */
    public void testGetUnsynchronizedFragments() throws Exception {
        MP3File mp3 = new MP3File();
        ID3v2_4 id3v2 = new ID3v2_4();
        ID3v1 id3v1 = new ID3v1();
        Lyrics3v2 lyrics3 = new Lyrics3v2();
        String albumTitle = "<album title>";
        mp3.setID3v2Tag(id3v2);
        mp3.setID3v1Tag(id3v1);
        mp3.setLyrics3Tag(lyrics3);
        mp3.setMp3file(new File(albumTitle));
        FilenameTag filename = FilenameTagBuilder.createFilenameTagFromMP3File(mp3);
        mp3.setFilenameTag(filename);
        AbstractID3v2Frame frame;
        AbstractID3v2FrameBody body;

        // test nulls;
        assertEquals(0, mp3.getUnsynchronizedFragments().size());

        // test equals
        body = new FrameBodyTALB((byte) 0, albumTitle);
        frame = new ID3v2_4Frame(body);
        id3v2.setFrame(frame);
        assertEquals(0, mp3.getUnsynchronizedFragments().size());
        lyrics3.setField(new Lyrics3v2Field(frame));
        assertEquals(0, mp3.getUnsynchronizedFragments().size());
        id3v1.setAlbum(albumTitle);
        assertEquals(0, mp3.getUnsynchronizedFragments().size());
        filename.setFrame(frame);
        assertEquals(0, mp3.getUnsynchronizedFragments().size());

        // test differences
        body = new FrameBodyTIT2((byte) 0, "<song title>");
        frame = new ID3v2_4Frame();
        frame.setBody(body);
        filename.setFrame(frame);
        assertEquals(0, mp3.getUnsynchronizedFragments().size());
        id3v1.setTitle("different");
        assertEquals(1, mp3.getUnsynchronizedFragments().size());
        id3v1.setTitle("<song title>");
        assertEquals(0, mp3.getUnsynchronizedFragments().size());
        lyrics3.setField(new Lyrics3v2Field(new FieldBodyETT("different")));
        assertEquals(1, mp3.getUnsynchronizedFragments().size());
        lyrics3.setField(new Lyrics3v2Field(new FieldBodyETT("<song title>")));
        assertEquals(0, mp3.getUnsynchronizedFragments().size());
        body = new FrameBodyTIT2((byte) 0, "different");
        frame = new ID3v2_4Frame(body);
        id3v2.setFrame(frame);
        assertEquals(1, mp3.getUnsynchronizedFragments().size());

        // test two differences
        id3v1.setArtist("<song artist>");
        assertEquals(1, mp3.getUnsynchronizedFragments().size());
        body = new FrameBodyTPE1((byte) 0, "different");
        frame = new ID3v2_4Frame();
        frame.setBody(body);
        filename.setFrame(frame);
        assertEquals(2, mp3.getUnsynchronizedFragments().size());
        body = new FrameBodyTPE1((byte) 0, "<song artist>");
        frame = new ID3v2_4Frame();
        frame.setBody(body);
        filename.setFrame(frame);
        assertEquals(1, mp3.getUnsynchronizedFragments().size());
        lyrics3.setField(new Lyrics3v2Field(new FieldBodyEAR("different")));
        assertEquals(2, mp3.getUnsynchronizedFragments().size());
        lyrics3.setField(new Lyrics3v2Field(new FieldBodyEAR("<song artist>")));
        assertEquals(1, mp3.getUnsynchronizedFragments().size());
        body = new FrameBodyTPE1((byte) 0, "different");
        frame = new ID3v2_4Frame(body);
        id3v2.setFrame(frame);
        assertEquals(2, mp3.getUnsynchronizedFragments().size());
View Full Code Here


        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);
        frame = new ID3v2_4Frame(frameBody);
        id3v2.setFrame(frame);

        // setup lyrics3v2
        Lyrics3v2Field field;
        AbstractLyrics3v2FieldBody fieldBody;
        fieldBody = new FieldBodyEAL(albumTitle);
        field = new Lyrics3v2Field(fieldBody);
        lyrics3.setField(field);

        // setup filename tag
        frameBody = new FrameBodyTALB((byte) 0, albumTitle);
        frame = new ID3v2_4Frame(frameBody);
        filenameId3.setFrame(frame);
View Full Code Here

        ((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);
        frame.setBody(frameBody);
        mp3file.setFrameAcrossTags(frame);
View Full Code Here

        Lyrics3v1 copyTag = new Lyrics3v1(tag);
        assertEquals(copyTag, tag);
    }

    public void testLyrics3v2() {
        Lyrics3v2 tag = new Lyrics3v2();
        assertEquals("", tag.getSongTitle());
        assertEquals("", tag.getLeadArtist());
        assertEquals("", tag.getAlbumTitle());
        try {
            tag.getYearReleased();
            fail("Did not throw UnsupportedOperationException");
        } catch (UnsupportedOperationException ex) {
        }
        try {
            tag.getSongGenre();
            fail("Did not throw UnsupportedOperationException");
        } catch (UnsupportedOperationException ex) {
        }
        try {
            tag.getTrackNumberOnAlbum();
            fail("Did not throw UnsupportedOperationException");
        } catch (UnsupportedOperationException ex) {
        }
        assertEquals("", tag.getSongLyric());
        assertEquals("", tag.getAuthorComposer());
        tag = new Lyrics3v2();
        tag.setSongTitle(songTitle);
        tag.setLeadArtist(leadArtist);
        tag.setAlbumTitle(albumTitle);
        try {
            tag.setYearReleased(null);
            fail("Did not throw UnsupportedOperationException");
        } catch (UnsupportedOperationException ex) {
        }
        tag.setSongComment(songComment);
        try {
            tag.setSongGenre(null);
            fail("Did not throw UnsupportedOperationException");
        } catch (UnsupportedOperationException ex) {
        }
        try {
            tag.setTrackNumberOnAlbum(null);
            fail("Did not throw UnsupportedOperationException");
        } catch (UnsupportedOperationException ex) {
        }
        tag.setSongLyric(songLyric);
        tag.setAuthorComposer(authorComposer);
        assertEquals(songTitle, tag.getSongTitle());
        assertEquals(leadArtist, tag.getLeadArtist());
        assertEquals(albumTitle, tag.getAlbumTitle());
        assertEquals(songComment, tag.getSongComment());
        assertEquals(songLyric, tag.getSongLyric());
        assertEquals(authorComposer, tag.getAuthorComposer());

        // run again because it's a different case
        tag.setSongTitle(songTitle);
        tag.setLeadArtist(leadArtist);
        tag.setAlbumTitle(albumTitle);
        tag.setSongComment(songComment);
        tag.setSongLyric(songLyric);
        tag.setAuthorComposer(authorComposer);
        assertEquals(songTitle, tag.getSongTitle());
        assertEquals(leadArtist, tag.getLeadArtist());
        assertEquals(albumTitle, tag.getAlbumTitle());
        assertEquals(songComment, tag.getSongComment());
        assertEquals(songLyric, tag.getSongLyric());
        assertEquals(authorComposer, tag.getAuthorComposer());
        ID3v2_4 convertTag = new ID3v2_4(tag);
        Lyrics3v2 newTag = new Lyrics3v2(convertTag);
        assertEquals(tag, newTag);
        assertEquals(newTag.getSongTitle(), tag.getSongTitle());
        assertEquals(newTag.getLeadArtist(), tag.getLeadArtist());
        assertEquals(newTag.getAlbumTitle(), tag.getAlbumTitle());
        assertEquals(newTag.getSongComment(), tag.getSongComment());
        assertEquals(newTag.getSongLyric(), tag.getSongLyric());
        assertEquals(newTag.getAuthorComposer(), tag.getAuthorComposer());
        Lyrics3v2 copyTag = new Lyrics3v2(tag);
        assertEquals(copyTag, tag);
    }
View Full Code Here

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

            id3v2tag.setFrame(frame);
        }
        if (lyrics3tag != null) {
            final ID3v2_4 lyrics3 = new ID3v2_4(lyrics3tag);
            lyrics3.setFrame(frame);
            lyrics3tag = new Lyrics3v2(lyrics3);
        }
        if (filenameTag != null) {
            filenameTag.setFrame(frame);
        }
    }
View Full Code Here

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

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

                        this.setFrame(newFrame);
                    }
                }
            } else if (mp3tag instanceof AbstractLyrics3) {
                // put the conversion stuff in the individual frame code.
                final Lyrics3v2 lyric;
                if (mp3tag instanceof Lyrics3v2) {
                    lyric = new Lyrics3v2((Lyrics3v2) mp3tag);
                } else {
                    lyric = new Lyrics3v2(mp3tag);
                }
                final Iterator iterator = lyric.iterator();
                Lyrics3v2Field field;
                ID3v2_4Frame newFrame;
                while (iterator.hasNext()) {
                    try {
                        field = (Lyrics3v2Field) iterator.next();
View Full Code Here

        assertNull(lyrics3);
        assertTrue(filename != null);
        assertFalse(filename.hasFrame("TIT2"));
        lyrics3 = new Lyrics3v2();
        try {
            ((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
        } catch (TagException ex) {
            fail(ex.getMessage());
        }
        mp3file.setLyrics3Tag(lyrics3);
        assertEquals(3, mp3file.getFrameAcrossTags("TIT2").size());
        filename.setFrame(frame);
        assertEquals(4, mp3file.getFrameAcrossTags("TIT2").size());
        mp3file.setFilenameTag(null);
        assertEquals(3, mp3file.getFrameAcrossTags("TIT2").size());
        mp3file.setID3v2Tag(null);
        assertEquals(2, mp3file.getFrameAcrossTags("TIT2").size());
        mp3file.setID3v1Tag(null);
        assertEquals(1, mp3file.getFrameAcrossTags("TIT2").size());
        mp3file.setLyrics3Tag(null);
        assertEquals(0, mp3file.getFrameAcrossTags("TIT2").size());

        // test nulls
        assertNull(mp3file.getFrameAcrossTags(null));
        assertNull(mp3file.getFrameAcrossTags(""));

        // test all different fields
        List frameList;
        final String testString = "Test String";
        mp3file = new MP3File();
        frame = new ID3v2_4Frame(new FrameBodyTIT2((byte) 0, testString));
        id3v1 = new ID3v1_1();
        id3v2 = new ID3v2_4();
        lyrics3 = new Lyrics3v2();
        filename = FilenameTagBuilder.createEmptyFilenameTag();
        id3v1.setTitle(testString);
        id3v2.setFrame(frame);
        try {
            ((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
        } catch (TagException ex) {
            fail("This should not happen. " + ex.getMessage());
        }
        filename.setFrame(frame);

        // different nulls
        mp3file = new MP3File();
        mp3file.setID3v1Tag(null);
        mp3file.setID3v2Tag(null);
        mp3file.setLyrics3Tag(null);
        mp3file.setFilenameTag(null);
        frameList = mp3file.getFrameAcrossTags("TIT2");
        assertEquals(0, frameList.size());
        mp3file = new MP3File();
        mp3file.setID3v1Tag(id3v1);
        mp3file.setID3v2Tag(null);
        mp3file.setLyrics3Tag(null);
        mp3file.setFilenameTag(null);
        frameList = mp3file.getFrameAcrossTags("TIT2");
        assertEquals(1, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }
        mp3file = new MP3File();
        mp3file.setID3v1Tag(null);
        mp3file.setID3v2Tag(id3v2);
        mp3file.setLyrics3Tag(null);
        mp3file.setFilenameTag(null);
        frameList = mp3file.getFrameAcrossTags("TIT2");
        assertEquals(1, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }
        mp3file = new MP3File();
        mp3file.setID3v1Tag(null);
        mp3file.setID3v2Tag(null);
        mp3file.setLyrics3Tag(lyrics3);
        mp3file.setFilenameTag(null);
        frameList = mp3file.getFrameAcrossTags("TIT2");
        assertEquals(1, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }
        mp3file = new MP3File();
        mp3file.setID3v1Tag(null);
        mp3file.setID3v2Tag(null);
        mp3file.setLyrics3Tag(null);
        mp3file.setFilenameTag(filename);
        frameList = mp3file.getFrameAcrossTags("TIT2");
        assertEquals(1, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }
        mp3file = new MP3File();
        mp3file.setID3v1Tag(id3v1);
        mp3file.setID3v2Tag(id3v2);
        mp3file.setLyrics3Tag(null);
        mp3file.setFilenameTag(null);
        frameList = mp3file.getFrameAcrossTags("TIT2");
        assertEquals(2, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }
        mp3file = new MP3File();
        mp3file.setID3v1Tag(id3v1);
        mp3file.setID3v2Tag(null);
        mp3file.setLyrics3Tag(lyrics3);
        mp3file.setFilenameTag(null);
        frameList = mp3file.getFrameAcrossTags("TIT2");
        assertEquals(2, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }
        mp3file = new MP3File();
        mp3file.setID3v1Tag(id3v1);
        mp3file.setID3v2Tag(null);
        mp3file.setLyrics3Tag(null);
        mp3file.setFilenameTag(filename);
        frameList = mp3file.getFrameAcrossTags("TIT2");
        assertEquals(2, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }
        mp3file = new MP3File();
        mp3file.setID3v1Tag(null);
        mp3file.setID3v2Tag(id3v2);
        mp3file.setLyrics3Tag(lyrics3);
        mp3file.setFilenameTag(null);
        frameList = mp3file.getFrameAcrossTags("TIT2");
        assertEquals(2, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }
        mp3file = new MP3File();
        mp3file.setID3v1Tag(null);
        mp3file.setID3v2Tag(id3v2);
        mp3file.setLyrics3Tag(null);
        mp3file.setFilenameTag(filename);
        frameList = mp3file.getFrameAcrossTags("TIT2");
        assertEquals(2, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }
        mp3file = new MP3File();
        mp3file.setID3v1Tag(null);
        mp3file.setID3v2Tag(null);
        mp3file.setLyrics3Tag(lyrics3);
        mp3file.setFilenameTag(filename);
        frameList = mp3file.getFrameAcrossTags("TIT2");
        assertEquals(2, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }
        mp3file = new MP3File();
        mp3file.setID3v1Tag(id3v1);
        mp3file.setID3v2Tag(id3v2);
        mp3file.setLyrics3Tag(lyrics3);
        mp3file.setFilenameTag(null);
        frameList = mp3file.getFrameAcrossTags("TIT2");
        assertEquals(3, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }
        mp3file = new MP3File();
        mp3file.setID3v1Tag(id3v1);
        mp3file.setID3v2Tag(id3v2);
        mp3file.setLyrics3Tag(null);
        mp3file.setFilenameTag(filename);
        frameList = mp3file.getFrameAcrossTags("TIT2");
        assertEquals(3, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }
        mp3file = new MP3File();
        mp3file.setID3v1Tag(id3v1);
        mp3file.setID3v2Tag(null);
        mp3file.setLyrics3Tag(lyrics3);
        mp3file.setFilenameTag(filename);
        frameList = mp3file.getFrameAcrossTags("TIT2");
        assertEquals(3, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }
        mp3file = new MP3File();
        mp3file.setID3v1Tag(null);
        mp3file.setID3v2Tag(id3v2);
        mp3file.setLyrics3Tag(lyrics3);
        mp3file.setFilenameTag(filename);
        frameList = mp3file.getFrameAcrossTags("TIT2");
        assertEquals(3, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }

        // TEST each frame
        // TIT1
        mp3file = new MP3File();
        mp3file.setID3v1Tag(id3v1);
        mp3file.setID3v2Tag(id3v2);
        mp3file.setLyrics3Tag(lyrics3);
        mp3file.setFilenameTag(filename);
        frameList = mp3file.getFrameAcrossTags("TIT2");
        assertEquals(4, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }

        // TPE1
        mp3file = new MP3File();
        id3v1 = new ID3v1_1();
        id3v2 = new ID3v2_4();
        lyrics3 = new Lyrics3v2();
        filename = FilenameTagBuilder.createEmptyFilenameTag();
        frame = new ID3v2_4Frame(new FrameBodyTPE1((byte) 0, testString));
        id3v1.setArtist(testString);
        id3v2.setFrame(frame);
        try {
            ((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
        } catch (TagException ex) {
            fail("This should not happen. " + ex.getMessage());
        }
        filename.setFrame(frame);
        mp3file.setID3v1Tag(id3v1);
        mp3file.setID3v2Tag(id3v2);
        mp3file.setLyrics3Tag(lyrics3);
        mp3file.setFilenameTag(filename);
        frameList = mp3file.getFrameAcrossTags("TPE1");
        assertEquals(4, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }

        // TALB
        mp3file = new MP3File();
        id3v1 = new ID3v1_1();
        id3v2 = new ID3v2_4();
        lyrics3 = new Lyrics3v2();
        filename = FilenameTagBuilder.createEmptyFilenameTag();
        frame = new ID3v2_4Frame(new FrameBodyTALB((byte) 0, testString));
        id3v1.setAlbum(testString);
        id3v2.setFrame(frame);
        try {
            ((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
        } catch (TagException ex) {
            fail("This should not happen. " + ex.getMessage());
        }
        filename.setFrame(frame);
        mp3file.setID3v1Tag(id3v1);
        mp3file.setID3v2Tag(id3v2);
        mp3file.setLyrics3Tag(lyrics3);
        mp3file.setFilenameTag(filename);
        frameList = mp3file.getFrameAcrossTags("TALB");
        assertEquals(4, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }

        // TDRC
        mp3file = new MP3File();
        id3v1 = new ID3v1_1();
        id3v2 = new ID3v2_4();
        lyrics3 = new Lyrics3v2();
        filename = FilenameTagBuilder.createEmptyFilenameTag();
        frame = new ID3v2_4Frame(new FrameBodyTDRC((byte) 0, "1992"));
        id3v1.setYear("1992");
        id3v2.setFrame(frame);
        try {
            ((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
            fail("Somehow created a TDRC (year) Lyrics3v2 Field");
        } catch (TagException ex) {
            // correct behavior
        }
        filename.setFrame(frame);
        mp3file.setID3v1Tag(id3v1);
        mp3file.setID3v2Tag(id3v2);
        mp3file.setLyrics3Tag(lyrics3);
        mp3file.setFilenameTag(filename);
        frameList = mp3file.getFrameAcrossTags("TDRC");
        assertEquals(3, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }

        // COMM
        mp3file = new MP3File();
        id3v1 = new ID3v1_1();
        id3v2 = new ID3v2_4();
        lyrics3 = new Lyrics3v2();
        filename = FilenameTagBuilder.createEmptyFilenameTag();
        frame = new ID3v2_4Frame(new FrameBodyCOMM((byte) 0, "ENG", "", testString));
        id3v1.setComment(testString);
        id3v2.setFrame(frame);
        try {
            ((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
        } catch (TagException ex) {
            fail("This should not happen. " + ex.getMessage());
        }
        filename.setFrame(frame);
        mp3file.setID3v1Tag(id3v1);
        mp3file.setID3v2Tag(id3v2);
        mp3file.setLyrics3Tag(lyrics3);
        mp3file.setFilenameTag(filename);
        frameList = mp3file.getFrameAcrossTags("COMM");
        assertEquals(4, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }

        // TCON
        mp3file = new MP3File();
        id3v1 = new ID3v1_1();
        id3v2 = new ID3v2_4();
        lyrics3 = new Lyrics3v2();
        filename = FilenameTagBuilder.createEmptyFilenameTag();
        frame = new ID3v2_4Frame(new FrameBodyTCON((byte) 0, "(42) Soul"));
        id3v1.setGenre((byte) 42);
        id3v2.setFrame(frame);
        try {
            ((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
            fail("Somehow created a TCON (genre) Lyrics3v2 Field");
        } catch (TagException ex) {
            // correct behavior
        }
        filename.setFrame(frame);
        mp3file.setID3v1Tag(id3v1);
        mp3file.setID3v2Tag(id3v2);
        mp3file.setLyrics3Tag(lyrics3);
        mp3file.setFilenameTag(filename);
        frameList = mp3file.getFrameAcrossTags("TCON");
        assertEquals(3, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }

        // TRCK
        mp3file = new MP3File();
        id3v1 = new ID3v1_1();
        id3v2 = new ID3v2_4();
        lyrics3 = new Lyrics3v2();
        filename = FilenameTagBuilder.createEmptyFilenameTag();
        frame = new ID3v2_4Frame(new FrameBodyTRCK((byte) 0, "42"));
        ((ID3v1_1) id3v1).setTrack((byte) 42);
        id3v2.setFrame(frame);
        try {
            ((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
            fail("Somehow created a TRCK (track) Lyrics3v2 Field");
        } catch (TagException ex) {
            // correct behavior
        }
        filename.setFrame(frame);
        mp3file.setID3v1Tag(id3v1);
        mp3file.setID3v2Tag(id3v2);
        mp3file.setLyrics3Tag(lyrics3);
        mp3file.setFilenameTag(filename);
        frameList = mp3file.getFrameAcrossTags("TRCK");
        assertEquals(3, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }

        // SYLT
        mp3file = new MP3File();
        id3v1 = new ID3v1_1();
        id3v2 = new ID3v2_4();
        lyrics3 = new Lyrics3v2();
        filename = FilenameTagBuilder.createEmptyFilenameTag();
        frame = new ID3v2_4Frame(new FrameBodySYLT((byte) 0, "ENG", (byte) 0, (byte) 0, "description"));
        ((FrameBodySYLT) frame.getBody()).addLyric(0, testString);
        id3v2.setFrame(frame);
        try {
            ((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
        } catch (TagException ex) {
            fail("This should not happen. " + ex.getMessage());
        }
        filename.setFrame(frame);
        mp3file.setID3v1Tag(id3v1);
        mp3file.setID3v2Tag(id3v2);
        mp3file.setLyrics3Tag(lyrics3);
        mp3file.setFilenameTag(filename);
        frameList = mp3file.getFrameAcrossTags("SYLT");
        assertEquals(3, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }

        // USLT
        mp3file = new MP3File();
        id3v1 = new ID3v1_1();
        id3v2 = new ID3v2_4();
        lyrics3 = new Lyrics3v2();
        filename = FilenameTagBuilder.createEmptyFilenameTag();
        frame = new ID3v2_4Frame(new FrameBodyUSLT((byte) 0, "ENG", "", testString));
        id3v2.setFrame(frame);
        try {
            ((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
        } catch (TagException ex) {
            fail("This should not happen. " + ex.getMessage());
        }
        filename.setFrame(frame);
        mp3file.setID3v1Tag(id3v1);
        mp3file.setID3v2Tag(id3v2);
        mp3file.setLyrics3Tag(lyrics3);
        mp3file.setFilenameTag(filename);
        frameList = mp3file.getFrameAcrossTags("USLT");
        assertEquals(3, frameList.size());
        for (int i = 0; i < frameList.size(); i++) {
            assertEquals(frame, frameList.get(i));
        }

        // TCOM
        mp3file = new MP3File();
        id3v1 = new ID3v1_1();
        id3v2 = new ID3v2_4();
        lyrics3 = new Lyrics3v2();
        filename = FilenameTagBuilder.createEmptyFilenameTag();
        frame = new ID3v2_4Frame(new FrameBodyTCOM((byte) 0, testString));
        id3v2.setFrame(frame);
        try {
            ((Lyrics3v2) lyrics3).setField(new Lyrics3v2Field(frame));
        } catch (TagException ex) {
            fail("This should not happen. " + ex.getMessage());
        }
        filename.setFrame(frame);
        mp3file.setID3v1Tag(id3v1);
View Full Code Here

TOP

Related Classes of org.farng.mp3.lyrics3.Lyrics3v1Iterator

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.