Package org.farng.mp3.id3

Examples of org.farng.mp3.id3.AbstractID3v2FrameBody


    public ID3v2_4 createId3Tag() {
        final ID3v2_4 newTag = new ID3v2_4();
        if (id3v2FrameBodyClass != null) {
            try {
                final AbstractID3v2FrameBody body = (AbstractID3v2FrameBody) id3v2FrameBodyClass.newInstance();

                //todo need to add support for more frame bodies here
                if (body instanceof AbstractFrameBodyTextInformation) {
                    ((AbstractFrameBodyTextInformation) body).setText(token);
                    ((AbstractFrameBodyTextInformation) body).setTextEncoding((byte) 0);
View Full Code Here


            } else {
                tag = new ID3v2_4(matchTag);
            }
            final Iterator iterator = tag.iterator();
            AbstractID3v2Frame frame;
            AbstractID3v2FrameBody body;
            String matchString = null;
            final String lowerCaseToken = token.toLowerCase();
            while (iterator.hasNext()) {
                frame = (ID3v2_4Frame) iterator.next();
                body = (AbstractID3v2FrameBody) frame.getBody();
                //todo add support for more tag matches. only doing text
                //      information and URL links right now because i'm lazy
                if (body instanceof AbstractFrameBodyTextInformation) {
                    matchString = ((AbstractFrameBodyTextInformation) body).getText();
                    if (matchString != null) {
                        matchString = matchString.toLowerCase();
                    }
                } else if (body instanceof AbstractFrameBodyUrlLink) {
                    matchString = ((AbstractFrameBodyUrlLink) body).getUrlLink();
                    if (matchString != null) {
                        matchString = matchString.toLowerCase();
                    }
                } else if (body instanceof FrameBodyCOMM) {
                    matchString = ((FrameBodyCOMM) body).getText();
                }
                if (lowerCaseToken.equals(matchString) ||
                    matchString != null &&
                    (matchString.indexOf(lowerCaseToken) >= 0 || lowerCaseToken.indexOf(matchString) >= 0)) {
                    setId3v2FrameBodyClass(body.getClass());
                    break;
                }
            }
        }
    }
View Full Code Here

        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) {
View Full Code Here

        ((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()
View Full Code Here

        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) {
View Full Code Here

        ((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);
View Full Code Here

        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) {
View Full Code Here

        // 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());
View Full Code Here

        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);
        TagOptionSingleton.getInstance().setFilenameTagSave(true);

        // nulls
View Full Code Here

    public void testSetFrameAcrossTags() throws Exception {
        MP3File mp3file = new MP3File();
        String testString = "Test String";
        AbstractID3v2Frame frame;
        AbstractID3v2FrameBody frameBody;
        frameBody = new FrameBodyTALB((byte) 0, testString);
        frame = new ID3v2_4Frame(frameBody);

        // nulls
        mp3file.setFrameAcrossTags(null);
        mp3file.setID3v1Tag(null);
        mp3file.setID3v2Tag(null);
        mp3file.setLyrics3Tag(null);
        mp3file.setFilenameTag(null);
        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);
View Full Code Here

TOP

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

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.