Package org.jaudiotagger.audio

Examples of org.jaudiotagger.audio.AudioHeader


        metaData.setTrackNr(toFirstNumber(getTagField(tag, TRACK)));
        metaData.setTrackNrs(toShort(getTagField(tag, TRACK_TOTAL)));
        metaData.setCoverArtEmbedded(tag.getFirstArtwork() != null);
      }

      AudioHeader audioHeader = audioFile.getAudioHeader();
      if (audioHeader != null) {
        metaData.setVbr(audioHeader.isVariableBitRate());
        metaData.setBitrate((short) audioHeader.getBitRateAsNumber());
        metaData.setDuration((short) audioHeader.getTrackLength());
      }

      file.setMetaData(metaData);
     
    } catch (CannotReadException | IOException | TagException
View Full Code Here


 
  private void readTagsFromFile() {
    try {
      AudioFile f = AudioFileIO.read(new File(_fileName));
     
      AudioHeader ah = f.getAudioHeader();
      Tag tag = f.getTag();
     
      _title = tag.getFirstTitle();
      _artist = tag.getFirstArtist();
      _album = tag.getFirstAlbum();
      _trackNumber = tag.getFirstTrack();
      _trackLength = ah.getTrackLength()
      _genre = tag.getFirstGenre();
      _year = tag.getFirstYear()
      _comment = tag.getFirstComment();

    } catch (Exception e) {
View Full Code Here

    String year = ""; //$NON-NLS-1$
    String comment = ""; //$NON-NLS-1$
    try {
      AudioFile f = AudioFileIO.read(new File(fileName));
     
      AudioHeader ah = f.getAudioHeader();
      Tag tag = f.getTag();
     
      try {
        title = tag.getFirstTitle().replaceAll("'", "''"); //$NON-NLS-1$ //$NON-NLS-2$
      } catch (Exception e) {
        Log.getInstance(PlaylistController.class).warn("Error while reading title property : " + fileName + " (" + e.toString() +")."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      }
      try {
        artist = tag.getFirstArtist().replaceAll("'", "''"); //$NON-NLS-1$ //$NON-NLS-2$
      } catch (Exception e) {
        Log.getInstance(PlaylistController.class).warn("Error while reading artist property : " + fileName + " (" + e.toString() +")."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      }
      try {
        album = tag.getFirstAlbum().replaceAll("'", "''"); //$NON-NLS-1$ //$NON-NLS-2$
      } catch (Exception e) {
        Log.getInstance(PlaylistController.class).warn("Error while reading album property : " + fileName + " (" + e.toString() +")."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      }
      try {
        trackNumber = tag.getFirstTrack().replaceAll("'", "''");       //$NON-NLS-1$ //$NON-NLS-2$
      } catch (Exception e) {
        Log.getInstance(PlaylistController.class).warn("Error while reading trackNumber property : " + fileName + " (" + e.toString() +")."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      }
      try {
        trackLength = ah.getTrackLength();
      } catch (Exception e) {
        Log.getInstance(PlaylistController.class).warn("Error while reading trackLength property : " + fileName + " (" + e.toString() +")."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      }
      try {
        genre = tag.getFirstGenre().replaceAll("'", "''"); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

        }
       
        try {
          audioFile = AudioFileIO.read(file);
         
          AudioHeader header = audioFile.getAudioHeader();
         
          songFile.setTrackLength(header.getTrackLength());
          songFile.setBitRate(header.getBitRate());
          songFile.setEncoding(header.getEncodingType());
         
          tag = audioFile.getTag();
          if (tag != null) {
            List<TagField> artistFields = tag.getFields(FieldKey.ARTIST);
            for (TagField artistField : artistFields) {
View Full Code Here

        DLNAMediaAudio audio = new DLNAMediaAudio();

        if (file != null) {
          try {
            AudioFile af = AudioFileIO.read(file);
            AudioHeader ah = af.getAudioHeader();

            if (ah != null && !thumbOnly) {
              int length = ah.getTrackLength();
              int rate = ah.getSampleRateAsNumber();

              if (ah.getEncodingType().toLowerCase().contains("flac 24")) {
                audio.setBitsperSample(24);
              }

              audio.setSampleFrequency("" + rate);
              durationSec = (double) length;
              bitrate = (int) ah.getBitRateAsNumber();
              audio.getAudioProperties().setNumberOfChannels(2);

              if (ah.getChannels() != null && ah.getChannels().toLowerCase().contains("mono")) {
                audio.getAudioProperties().setNumberOfChannels(1);
              } else if (ah.getChannels() != null && ah.getChannels().toLowerCase().contains("stereo")) {
                audio.getAudioProperties().setNumberOfChannels(2);
              } else if (ah.getChannels() != null) {
                audio.getAudioProperties().setNumberOfChannels(Integer.parseInt(ah.getChannels()));
              }

              audio.setCodecA(ah.getEncodingType().toLowerCase());

              if (audio.getCodecA().contains("(windows media")) {
                audio.setCodecA(audio.getCodecA().substring(0, audio.getCodecA().indexOf("(windows media")).trim());
              }
            }
View Full Code Here

        DLNAMediaAudio audio = new DLNAMediaAudio();

        if (inputFile.getFile() != null) {
          try {
            AudioFile af = AudioFileIO.read(inputFile.getFile());
            AudioHeader ah = af.getAudioHeader();

            if (ah != null && !thumbOnly) {
              int length = ah.getTrackLength();
              int rate = ah.getSampleRateAsNumber();

              if (ah.getEncodingType().toLowerCase().contains("flac 24")) {
                audio.setBitsperSample(24);
              }

              audio.setSampleFrequency("" + rate);
              setDuration((double) length);
              setBitrate((int) ah.getBitRateAsNumber());
              audio.getAudioProperties().setNumberOfChannels(2);

              if (ah.getChannels() != null && ah.getChannels().toLowerCase().contains("mono")) {
                audio.getAudioProperties().setNumberOfChannels(1);
              } else if (ah.getChannels() != null && ah.getChannels().toLowerCase().contains("stereo")) {
                audio.getAudioProperties().setNumberOfChannels(2);
              } else if (ah.getChannels() != null) {
                audio.getAudioProperties().setNumberOfChannels(Integer.parseInt(ah.getChannels()));
              }

              audio.setCodecA(ah.getEncodingType().toLowerCase());

              if (audio.getCodecA().contains("(windows media")) {
                audio.setCodecA(audio.getCodecA().substring(0, audio.getCodecA().indexOf("(windows media")).trim());
              }
            }
View Full Code Here

TOP

Related Classes of org.jaudiotagger.audio.AudioHeader

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.