Package org.cmc.music.myid3.id3v1

Examples of org.cmc.music.myid3.id3v1.MyID3v1


    byte id3v1Tag[] = new MyID3v1().toTag(listener, values, strict);
    if (listener != null)
      listener.log("writing id3v1Tag", id3v1Tag == null ? "null" : ""
          + id3v1Tag.length);

    byte id3v2TailTag[] = new MyID3v2Write().toTag(listener, filter, set,
        values, strict);
    if (listener != null)
      listener.log("writing id3v2TailTag", id3v2TailTag == null ? "null"
          : "" + id3v2TailTag.length);
View Full Code Here


        }
    }

    private void precisaCriar() {
        //  if (mp3File.hasID3v1Tag()) {
        ID3v1 id = new ID3v1();
        id.setSongTitle(jTextField_Titulo.getText());
        id.setAlbumTitle(jTextField_Album.getText());
        id.setLeadArtist(jTextField_Interp.getText());
//         id.setSongGenre((String)(jComboBoxGenero.getSelectedItem()));
        id.setYearReleased(jTextField_ano.getText());
        id.setSongComment(jTextField_Comentario.getText());
        mp3File.setID3v1Tag(id);
        alterarMusica();
        try {
            mp3File.save(TagConstant.MP3_FILE_SAVE_APPEND);
            // }
View Full Code Here

     *
     */
    public void testGetFrameAcrossTags() {
        MP3File mp3file = this.testMusicArray[0];
        AbstractID3v2 id3v2 = mp3file.getID3v2Tag();
        ID3v1 id3v1 = mp3file.getID3v1Tag();
        AbstractLyrics3 lyrics3 = mp3file.getLyrics3Tag();
        FilenameTag filename = mp3file.getFilenameTag();
        AbstractID3v2Frame frame = id3v2.getFrame("TIT2");
        assertEquals(2, mp3file.getFrameAcrossTags("TIT2").size());
        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) {
View Full Code Here

     * @throws Exception
     */
    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);
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

    }
    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

TOP

Related Classes of org.cmc.music.myid3.id3v1.MyID3v1

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.