Package org.jaudiotagger.tag.id3

Examples of org.jaudiotagger.tag.id3.ID3v1Tag


            dataset = new DataSet();
        }
        RandomAccessFile raf = null;
        try {
            raf = new RandomAccessFile(file, "r");
            Id3v1Tag tag = new Id3v1TagReader().read(raf);
            if (tag != null) {
                dataset.setTrack(tag.getFirstTrack());
                dataset.setAlbum(tag.getFirstAlbum());
                dataset.setArtist(tag.getFirstArtist());
                dataset.setComment(tag.getFirstComment());
                dataset.setGenre(tag.getFirstGenre());
                dataset.setTitle(tag.getFirstTitle());
                dataset.setYear(tag.getFirstYear());
                return dataset;
            }
        } catch (Exception e) {
            logger.debug("Couldn't read version 1 tag:\n\t" + e);
        } finally {
View Full Code Here


    private boolean setV1Tag(File file, DataSet dataset) {
        RandomAccessFile raf = null;
        try {
            raf = new RandomAccessFile(file, "rw");

            Id3v1Tag tag = new Id3v1Tag();

            tag.setTitle(dataset.getTitle());
            tag.setTrack(dataset.getTrack());
            tag.setArtist(dataset.getArtist());
            tag.setAlbum(dataset.getAlbum());
            tag.setGenre(dataset.getGenre());
            tag.setComment(dataset.getComment());
            tag.setYear(dataset.getYear());

            new Id3v1TagWriter().write(tag, raf);
            return true;
        } catch (Exception e) {
            logger.warn("Couldn't write ID3V1 tag", e);
View Full Code Here

  }

  public void persist(String directory) {
    MP3File mp3File = new MP3File(new File(directory + getFull()));
    ID3V1Tag tag1 = null;
    try {
      tag1 = mp3File.getID3V1Tag();
      if(tag1==null){
        tag1 = new ID3V1_0Tag();
      }
    } catch (ID3Exception e) {
      tag1 = new ID3V1_0Tag();
    }
    if(!"".equals(getTitle())) tag1.setTitle(getTitle());
    tag1.setAlbum(getAlbum());
    tag1.setArtist(getArtist());
    tag1.setComment(getComment());
    try {
      tag1.setGenre(Genre.lookupGenre(getGenre()));
    } catch (ID3Exception e) {
    }
    tag1.setYear(getYear());
    mp3File.setID3Tag(tag1);
    try {
      mp3File.sync();
    } catch (ID3Exception e) {
    }
View Full Code Here

                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

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.