Package entagged.audioformats

Examples of entagged.audioformats.Tag


  public String[] createFrom(AudioFile audioFile, Integer bitrate)
      throws MissingValueException {
    ArrayList result = new ArrayList();
    StringBuffer buffer = new StringBuffer();
    ArrayList missingTags = new ArrayList();
    Tag tag = audioFile.getTag();
    Iterator sectionIt = sections.iterator();
    while (sectionIt.hasNext()) {
      buffer.delete(0, buffer.length());
      Section current = (Section) sectionIt.next();
      if (current.fileDirectory) {
        String absParentPath = audioFile.getParentFile()
            .getAbsolutePath();
        String[] splitted = saveSplit(absParentPath, File.separator);
        for (int i = 0; i < splitted.length; i++) {
          result.add(splitted[i]);
        }
      } else {
        for (int i = 0; i < current.parts.length; i++) {
          if (current.parts[i] instanceof String) {
            buffer.append(current.parts[i].toString());
          } else {
            int index = ((Integer) current.parts[i]).intValue();
            String value = null;
            switch (index) {
            case 0:
              value = tag.getFirstArtist();
              break;
            case 1:
              value = tag.getFirstAlbum();
              break;
            case 2:
              value = tag.getFirstTitle();
              break;
            case 3:
              value = tag.getFirstTrack();
              break;
            case 4:
              value = tag.getFirstGenre();
              break;
            case 5:
              value = tag.getFirstYear();
              break;
            case 6:
              value = tag.getFirstComment();
              break;
            case 7:
              if (bitrate != null) {
                value = bitrate.toString();
              } else {
View Full Code Here


    if (parts == null) {
      return audioFile.getName();
    }
    StringBuffer result = new StringBuffer();
    ArrayList missingTags = new ArrayList();
    Tag tag = audioFile.getTag();
    for (int i = 0; i < parts.length; i++) {
      if (parts[i] instanceof String) {
        result.append(parts[i].toString());
      } else {
        int index = ((Integer) parts[i]).intValue();
        String value = null;
        switch (index) {
        case 0:
          value = tag.getFirstArtist();
          break;
        case 1:
          value = tag.getFirstAlbum();
          break;
        case 2:
          value = tag.getFirstTitle();
          break;
        case 3:
          value = tag.getFirstTrack();
          break;
        case 4:
          value = tag.getFirstGenre();
          break;
        case 5:
          value = tag.getFirstYear();
          break;
        case 6:
          value = tag.getFirstComment();
          break;
        case 7:
          value = String.valueOf(audioFile.getBitrate());
          break;
        }
View Full Code Here

      raf = new RandomAccessFile( f, "r" );
      raf.seek( 0 );
     
      EncodingInfo info = getEncodingInfo(raf);
   
      Tag tag;
      try {
        raf.seek( 0 );
        tag = getTag(raf);
      } catch (CannotReadException e) {
        System.err.println(e.getMessage());
View Full Code Here

    public ByteBuffer convert(Tag tag) throws UnsupportedEncodingException {
        return convert(tag, 0);
    }
   
    public ByteBuffer convert(Tag tag, int padding) throws UnsupportedEncodingException {
        Tag compatibleTag = getCompatibleTag(tag);
       
        List fields = createFields(compatibleTag);
    int tagSize = computeTagLength(compatibleTag, fields);
   
    ByteBuffer buf = ByteBuffer.allocate( tagSize + padding );
View Full Code Here

   
    return length;
  }
 
  public int getTagLength(Tag tag) throws UnsupportedEncodingException {
      Tag compatibleTag = getCompatibleTag(tag);
    List fields = createFields(compatibleTag);
    return computeTagLength(compatibleTag, fields);
  }
View Full Code Here

      super(tagEditorFrame, audioFiles);
    }

    protected void audioFileAction(AudioFile af)
        throws CannotWriteException {
      Tag tag = af.getTag();

      System.out.println("Tagging file: " + af.getName());

      String VARIES_PATTERN = "\\Q" + VARIES + "\\E";

      if (!title.equals(VARIES)) {
        tag.setTitle(title.replaceAll(VARIES_PATTERN, tag
            .getFirstTitle()));
      }

      if (!artist.equals(VARIES)) {
        tag.setArtist(artist.replaceAll(VARIES_PATTERN, tag
            .getFirstArtist()));
      }

      if (!album.equals(VARIES)) {
        tag.setAlbum(album.replaceAll(VARIES_PATTERN, tag
            .getFirstAlbum()));
      }

      if (!year.equals(VARIES)) {
        tag
            .setYear(year.replaceAll(VARIES_PATTERN, tag
                .getFirstYear()));
      }

      if (!comment.equals(VARIES)) {
        tag.setComment(comment.replaceAll(VARIES_PATTERN, tag
            .getFirstComment()));
      }

      if (!track.equals(VARIES)) {
        tag.setTrack(track.replaceAll(VARIES_PATTERN, tag
            .getFirstTrack()));
      }

      if (!genre.equals(VARIES)) {
        tag.setGenre(genre.replaceAll(VARIES_PATTERN, tag
            .getFirstGenre()));
      }

      this.transformSet.transformFirstCommons(tag);

      if (tag instanceof Id3v2Tag)
        tag
            .setEncoding(PreferencesManager
                .get("entagged.tag.encoding"));

      AudioFileIO.write(af);
    }
View Full Code Here

   * @see entagged.audioformats.generic.AudioFileReader#getTag(java.io.RandomAccessFile)
   */
  protected Tag getTag(RandomAccessFile raf) throws CannotReadException,
      IOException {
    raf.seek(0);
    Tag tag = null;
    try {
      AsfHeader header = AsfHeaderReader.readHeader(raf);
      if (header == null) {
        throw new CannotReadException(
            "Some values must have been "
View Full Code Here

    }
    else if (f.isDirectory() || !(f instanceof AudioFile))
      return "";
    else {
      AudioFile af = (AudioFile) f;
      Tag tag = af.getTag();

      switch (column) {
      case 2:
        return tag.getFirstArtist();
      case 3:
        return tag.getFirstAlbum();
      case 4:
        String ret = tag.getFirstTrack();
        try {
          if (Integer.parseInt(ret) == 0)
            return "";
        }
        catch (Exception e) {} /* return normally */
        return ret;
      case 5:
        return tag.getFirstTitle();
      case 6:
        return getLength(af.getLength());
      case 7:
        return tag.getFirstGenre();
      default:
        return "";
      }
    }
  }
View Full Code Here

          .getAudioFiles()).iterator();
      int i = 0;
      while (it.hasNext()) {
        AudioFile f = (AudioFile) it.next();

        Tag tag = f.getTag();
        tag.setTitle(fdbrr.getTrackTitle(i).trim());
        tag.setAlbum(ManualFreedbPanel.this.album.getText());
        tag.setGenre(ManualFreedbPanel.this.genre.getTextField()
            .getText());
        tag.setArtist(ManualFreedbPanel.this.artist.getText());
        tag.setYear(ManualFreedbPanel.this.year.getText());
        tag.setComment(ManualFreedbPanel.this.comment.getText());
        tag.setTrack(new DecimalFormat("00").format(fdbrr
            .getTrackNumber(i)));

        if (tag instanceof Id3v2Tag)
          tag.setEncoding(PreferencesManager
              .get("entagged.tag.encoding"));

        try {
          AudioFileIO.write(f);
        } catch (CannotWriteException e) {
View Full Code Here

    if (f.isDirectory()) {
      setAllVaries();
      addDirectory(f);
    } else if (f instanceof AudioFile) {
      Tag tag = ((AudioFile) f).getTag();

      merge("artist", tag.getFirstArtist());
      merge("album", tag.getFirstAlbum());
      merge("title", tag.getFirstTitle());
      merge("tracknumber", tag.getFirstTrack());
      merge("comment", tag.getFirstComment());
      merge("genre", tag.getFirstGenre());
      merge("year", tag.getFirstYear());

      addFile(f);
    }
  }
View Full Code Here

TOP

Related Classes of entagged.audioformats.Tag

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.