Package org.jaudiotagger.tag.id3

Examples of org.jaudiotagger.tag.id3.ID3v22Tag


                if (id3v2tag == null) {
                    id3v2tag = new ID3v24Tag();
                }
                copyTagFields(id3v2tag, track);

                ID3v11Tag id3v1Tag = new ID3v11Tag(id3v2tag);
                mp3File.setID3v1Tag(id3v1Tag);
                mp3File.setID3v2Tag(id3v2tag);

                mp3File.commit();
            } catch (Exception e) {
View Full Code Here


        setCleanedContent(concatenateStringParts(info, Integer.MAX_VALUE));
        setTitle(concatenateStringParts(info, 2));

      } else if (mp3file.hasID3v1Tag()) {
        ID3v1Tag tag = mp3file.getID3v1Tag();

        info.add(tag.getFirst(FieldKey.ARTIST).trim());
        info.add(tag.getFirst(FieldKey.ALBUM).trim());
        info.add(tag.getFirst(FieldKey.TITLE).trim());
        try {
          int year = new Integer(tag.getFirst(FieldKey.YEAR).trim()).intValue();
          if (year > 0) {
            info.add(tag.getFirst(FieldKey.YEAR).trim());
          }
        } catch (Exception ex) {
        }
        info.add(mp3file.getMP3AudioHeader().getTrackLengthAsString().trim());
        info.add(mp3file.getMP3AudioHeader().getBitRate().trim() + "kbps");
View Full Code Here

    try {
      AudioFile audioFile = AudioFileIO.read(testFile);
      Tag tag = audioFile.getTag();
      if (tag instanceof ID3v1Tag) {
        ID3v1Tag v1tag = (ID3v1Tag) tag;
        String title = v1tag.getFirst(FieldKey.TITLE);
        System.out.println(title);
      }
      if (tag instanceof ID3v23Tag) {
        ID3v23Tag v23tag = (ID3v23Tag) tag;
        String title = v23tag.getFirst(FieldKey.TITLE);
View Full Code Here

  public void mp3TagWriteTest() {
    File testFile = new File("src/com/life/audiotageditor/test/test.mp3"); //$NON-NLS-1$

    try {
      AudioFile audioFile = AudioFileIO.read(testFile);
      Tag tagv1 = new ID3v1Tag();
      tagv1.setField(FieldKey.ALBUM, "New Concept Engl"); //$NON-NLS-1$
      tagv1.setField(FieldKey.TITLE, "New Concept Engli"); //$NON-NLS-1$
      tagv1.setField(FieldKey.ARTIST, "New Concept Englis"); //$NON-NLS-1$
      audioFile.setTag(tagv1);

      Tag tagv23 = new ID3v23Tag();
      tagv23.setField(FieldKey.ALBUM, "New Concept En"); //$NON-NLS-1$
      tagv23.setField(FieldKey.TITLE, "New Concept En"); //$NON-NLS-1$
View Full Code Here

    }
  }

  public static void saveAudioFile(AudioFile audioFile, AudioTag audioTag) {
    try {
      Tag tagv1 = new ID3v1Tag();
      tagv1.setField(FieldKey.TITLE, audioTag.getTitle());
      tagv1.setField(FieldKey.ARTIST, audioTag.getArtist());
      tagv1.setField(FieldKey.ALBUM, audioTag.getAlbum());
      tagv1.setField(FieldKey.YEAR, audioTag.getYear());
      tagv1.setField(FieldKey.GENRE, audioTag.getGenre());
      tagv1.setField(FieldKey.COMMENT, audioTag.getComment());
      audioFile.setTag(tagv1);

      Tag tagv23 = new ID3v23Tag();
      tagv23.setField(FieldKey.ALBUM, audioTag.getAlbum());
      tagv23.setField(FieldKey.TITLE, audioTag.getTitle());
View Full Code Here

    }

    private void parseID3v1Tag( MP3File f ) {

        ID3v1Tag tag = f.getID3v1Tag();

        try {

            artistTitle = tag.getArtist().get(0).toString();
            albumTitle  = tag.getAlbum().get(0).toString();
            trackTitle  = tag.getTitle().get(0).toString();
            albumYear   = tag.getYear().get(0).toString();
            genre       = tag.getGenre().get(0).toString();

            String trackN = tag.getTrack().get(0).toString();

            if ( ! trackN.equals("") ) {
                try {
                    trackNumber = Integer.parseInt(trackN);
                } catch (final NumberFormatException e) {
View Full Code Here

     * @param file
     * @throws IOException
     */
    public void delete(RandomAccessFile file) throws IOException {
        long filePointer;
        ID3v1Tag id3v1tag = new ID3v1Tag();


    }
View Full Code Here

     */
    public void write(RandomAccessFile file) throws IOException {
        String str;
        int offset;
        byte[] buffer;
        ID3v1Tag id3v1tag;

        id3v1tag = null;

        delete(file);
        file.seek(file.length());

        buffer = new byte[lyric.length() + 11 + 9];

        str = "LYRICSBEGIN";

        for (int i = 0; i < str.length(); i++) {
            buffer[i] = (byte) str.charAt(i);
        }

        offset = str.length();

        str = ID3Tags.truncate(lyric, 5100);

        for (int i = 0; i < str.length(); i++) {
            buffer[i + offset] = (byte) str.charAt(i);
        }

        offset += str.length();

        str = "LYRICSEND";

        for (int i = 0; i < str.length(); i++) {
            buffer[i + offset] = (byte) str.charAt(i);
        }

        offset += str.length();

        file.write(buffer, 0, offset);

        if (id3v1tag != null) {
            id3v1tag.write(file);
        }
    }
View Full Code Here

        byte[] buffer = new byte[6 + 9];

        String str;
        Lyrics3v2Field field;
        Iterator<Lyrics3v2Field> iterator;
        ID3v1Tag id3v1tag;
        new ID3v1Tag();

        id3v1tag = null;

        delete(file);
        file.seek(file.length());

        filePointer = file.getFilePointer();

        str = "LYRICSBEGIN";

        for (int i = 0; i < str.length(); i++) {
            buffer[i] = (byte) str.charAt(i);
        }

        file.write(buffer, 0, str.length());

        // IND needs to go first. lets createField/update it and write it first.
        updateField("IND");
        field = fieldMap.get("IND");
        field.write(file);

        iterator = fieldMap.values().iterator();

        while (iterator.hasNext()) {
            field = iterator.next();

            String id = field.getIdentifier();
            boolean save = TagOptionSingleton.getInstance().getLyrics3SaveField(id);

            if ((!id.equals("IND")) && save) {
                field.write(file);
            }
        }

        size = file.getFilePointer() - filePointer;

        if (this.getSize() != size) {
            //logger.info("Lyrics3v2 size didn't match up while writing.");
            //logger.info("this.getsize()     = " + this.getSize());
            //logger.info("size (filePointer) = " + size);
        }

        str = Long.toString(size);

        for (int i = 0; i < (6 - str.length()); i++) {
            buffer[i] = (byte) '0';
        }

        offset += (6 - str.length());

        for (int i = 0; i < str.length(); i++) {
            buffer[i + offset] = (byte) str.charAt(i);
        }

        offset += str.length();

        str = "LYRICS200";

        for (int i = 0; i < str.length(); i++) {
            buffer[i + offset] = (byte) str.charAt(i);
        }

        offset += str.length();

        file.write(buffer, 0, offset);

        if (id3v1tag != null) {
            id3v1tag.write(file);
        }
    }
View Full Code Here

        return false;
    }

    private boolean isId3v22Tag() throws IOException {
        int id3tagsize;
        ID3v22Tag id3tag = new ID3v22Tag();
        ByteBuffer bb = ByteBuffer.allocate(AbstractID3v2Tag.TAG_HEADER_LENGTH);
        raf.seek(0);
        raf.getChannel().read(bb);
        if (id3tag.seek(bb)) {
            id3tagsize = id3tag.readSize(bb);
            raf.seek(id3tagsize);
            //FLAC Stream immediately after end of id3 tag
            if (isFlacHeader()) {
                return true;
            }
View Full Code Here

TOP

Related Classes of org.jaudiotagger.tag.id3.ID3v22Tag

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.