Package org.jaudiotagger.tag.id3

Examples of org.jaudiotagger.tag.id3.ID3v1Tag


     */
    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

        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);
        System.out.println(title);
      }
    } catch (CannotReadException e) {
      e.printStackTrace();
    } catch (IOException e) {
View Full Code Here

      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$
      tagv23.setField(FieldKey.ARTIST, "New Concept "); //$NON-NLS-1$
      tagv23.setField(FieldKey.TRACK, "1"); //$NON-NLS-1$
      audioFile.setTag(tagv23);

      AudioFileIO.write(audioFile);
    } catch (CannotReadException e) {
      e.printStackTrace();
View Full Code Here

      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());
      tagv23.setField(FieldKey.ARTIST, audioTag.getArtist());
      if (!audioTag.getTrack().isEmpty()) {
        tagv23.setField(FieldKey.TRACK, audioTag.getTrack());
      }
      tagv23.setField(FieldKey.YEAR, audioTag.getYear());
      tagv23.setField(FieldKey.GENRE, audioTag.getGenre());
      tagv23.setField(FieldKey.COMMENT, audioTag.getComment());
      tagv23.setField(FieldKey.ALBUM_ARTIST, audioTag.getAlbumArtist());
      audioFile.setTag(tagv23);

      AudioFileIO.write(audioFile);
    } catch (TagException e) {
      e.printStackTrace();
View Full Code Here

        return false;
    }

    private boolean isId3v23Tag() throws IOException {
        int id3tagsize;
        ID3v23Tag id3tag = new ID3v23Tag();
        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

            tag.deleteField(FieldKey.TRACK);
          tag.addField(tag.createField(FieldKey.TRACK, "0"));
        }

        TagField field = tag.getFirstField(FieldKey.TRACK_TOTAL);
      ID3v24Frame frame = (ID3v24Frame) field;
      FrameBodyTRCK body = (FrameBodyTRCK) frame.getBody();
      body.setTrackTotal(Integer.valueOf(trackData.getTrackTotal()));

      trackFieldUpdated = true;
      }
      if (!trackFieldUpdated) {
        tag.deleteField(FieldKey.TRACK);
      }

      if (!Util.isEmpty(trackData.getDisc())) {
        tag.deleteField(FieldKey.DISC_NO);
        tag.addField(tag.createField(FieldKey.DISC_NO, trackData.getDisc()));
        discFieldUpdated = true;
      }
      if (!Util.isEmpty(trackData.getDiscTotal())) {
        if (!discFieldUpdated) {
            tag.deleteField(FieldKey.DISC_NO);
          tag.addField(tag.createField(FieldKey.DISC_NO, "0"));
        }

        TagField field = tag.getFirstField(FieldKey.DISC_TOTAL);
      ID3v24Frame frame = (ID3v24Frame) field;
      FrameBodyTPOS body = (FrameBodyTPOS) frame.getBody();
      body.setDiscTotal(Integer.valueOf(trackData.getDiscTotal()));

        discFieldUpdated = true;
      }
      if (!discFieldUpdated) {
View Full Code Here

    try {
      MP3File mp3file = new MP3File(rawFile);
      ArrayList<String> info = new ArrayList<String>();

      if (mp3file.hasID3v2Tag()) {
        ID3v24Tag id3v24tag = mp3file.getID3v2TagAsv24();

        info.add(id3v24tag.getFirst(ID3v24Frames.FRAME_ID_ARTIST).trim());
        info.add(id3v24tag.getFirst(ID3v24Frames.FRAME_ID_ALBUM).trim());
        info.add(id3v24tag.getFirst(ID3v24Frames.FRAME_ID_TITLE).trim());
        try {
          int year = new Integer(id3v24tag.getFirst(ID3v24Frames.FRAME_ID_YEAR).trim()).intValue();
          if (year > 0) {
            info.add(id3v24tag.getFirst(ID3v24Frames.FRAME_ID_YEAR).trim());
          }
        } catch (Exception ex) {
        }
        info.add(mp3file.getMP3AudioHeader().getTrackLengthAsString().trim());
        info.add(mp3file.getMP3AudioHeader().getBitRate().trim() + "kbps");
View Full Code Here

        {
            AudioFile f = AudioFileIO.read(file);
            Tag tag = f.getTag();
            if (tag == null)
            {
                tag = new ID3v24Tag();
            }
            tag.setField(FieldKey.ALBUM, song.getAlbum());
            tag.setField(FieldKey.ALBUM_ARTIST, song.getAlbumArtist());
            tag.setField(FieldKey.ARTIST, song.getArtist());
            tag.setField(FieldKey.COMPOSER, song.getComposer());
View Full Code Here

TOP

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

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.