当前位置: 首页>>代码示例>>Java>>正文


Java InvalidAudioFrameException类代码示例

本文整理汇总了Java中org.jaudiotagger.audio.exceptions.InvalidAudioFrameException的典型用法代码示例。如果您正苦于以下问题:Java InvalidAudioFrameException类的具体用法?Java InvalidAudioFrameException怎么用?Java InvalidAudioFrameException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InvalidAudioFrameException类属于org.jaudiotagger.audio.exceptions包,在下文中一共展示了InvalidAudioFrameException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: from

import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException; //导入依赖的package包/类
public static Song from(final URI uri) {
	try {
		AudioFile f = AudioFileIO.read(new File(uri));
		Tag tag = f.getTag();

		String trackStr = tag.getFirst(FieldKey.TRACK);
		if (trackStr.isEmpty()) { return null; }

		Artist artist = new Artist(tag.getFirst(FieldKey.ARTIST));
		Artwork artwork = tag.getFirstArtwork();
		Album album = new Album(tag.getFirst(FieldKey.ALBUM), artwork);
		String title = tag.getFirst(FieldKey.TITLE);
		int track = Integer.parseInt(trackStr);
		Integer seconds = f.getAudioHeader().getTrackLength() + 1;

		return new Song(title, artist, album, track, seconds, uri);
	} catch (CannotReadException | IOException | TagException | InvalidAudioFrameException
			| ReadOnlyFileException e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:jakemanning,项目名称:boomer-tuner,代码行数:23,代码来源:Song.java

示例2: read

import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException; //导入依赖的package包/类
public AudioFile read(File f) throws CannotReadException, IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException
{
    if(logger.isLoggable(Level.CONFIG))
    {
        logger.config(ErrorMessage.GENERAL_READ.getMsg(path));
    }

    if (!f.canRead())
    {
        throw new NoReadPermissionsException(ErrorMessage.GENERAL_READ_FAILED_DO_NOT_HAVE_PERMISSION_TO_READ_FILE.getMsg(f.getAbsolutePath()));
    }

    if (f.length() <= MINIMUM_SIZE_FOR_VALID_AUDIO_FILE)
    {
        throw new CannotReadException(ErrorMessage.GENERAL_READ_FAILED_FILE_TOO_SMALL.getMsg(f.getAbsolutePath()));
    }

    GenericAudioHeader info = getEncodingInfo(f);
    Tag tag = getTag(f);
    return new AudioFile(f, info, tag);
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:22,代码来源:AudioFileReader2.java

示例3: isNextFrameValid

import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException; //导入依赖的package包/类
private boolean isNextFrameValid(ByteBuffer bb)
{
    boolean result = false;
    int currentPosition = bb.position();

    bb.position(bb.position() + mp3FrameHeader.getFrameLength());
    if (MPEGFrameHeader.isMPEGFrame(bb))
    {
        try
        {
            MPEGFrameHeader.parseMPEGHeader(bb);
            MP3AudioHeader.logger.finer("Check next frame confirms is an audio header ");
            result = true;
        }
        catch (InvalidAudioFrameException ex)
        {
            MP3AudioHeader.logger.finer("Check next frame has identified this is not an audio header");
            result = false;
        }
    }
    // Set back to the start of the previous frame
    bb.position(currentPosition);
    return result;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:25,代码来源:ByteArrayMP3AudioHeader.java

示例4: getMP3StartByte

import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException; //导入依赖的package包/类
/**
 * Used by tags when writing to calculate the location of the music file
 *
 * @param file
 * @return the location within the file that the audio starts
 * @throws java.io.IOException
 * @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
 */
public long getMP3StartByte(File file) throws InvalidAudioFrameException, IOException {
    try {
        //Read ID3v2 tag size (if tag exists) to allow audio header parsing to skip over tag
        long startByte = AbstractID3v2Tag.getV2TagSizeIfExists(file);

        MP3AudioHeader audioHeader = new MP3AudioHeader(file, startByte);
        if (startByte != audioHeader.getMp3StartByte()) {
            logger.config("First header found after tag:" + audioHeader);
            audioHeader = checkAudioStart(startByte, audioHeader);
        }
        return audioHeader.getMp3StartByte();
    } catch (InvalidAudioFrameException iafe) {
        throw iafe;
    } catch (IOException ioe) {
        throw ioe;
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:26,代码来源:MP3File.java

示例5: setModeExtension

import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException; //导入依赖的package包/类
/**
 * Sets the string representation of the mode extension of this frame
 * @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
 */
private void setModeExtension() throws InvalidAudioFrameException
{
    int index = (mpegBytes[BYTE_4] & MASK_MP3_MODE_EXTENSION) >> 4;
    if (layer == LAYER_III)
    {
        modeExtension = modeExtensionLayerIIIMap.get(index);
        if (getModeExtension() == null)
        {
            throw new InvalidAudioFrameException("Invalid Mode Extension");
        }
    }
    else
    {
        modeExtension = modeExtensionMap.get(index);
        if (getModeExtension() == null)
        {
            throw new InvalidAudioFrameException("Invalid Mode Extension");
        }
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:25,代码来源:MPEGFrameHeader.java

示例6: setSamplingRate

import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException; //导入依赖的package包/类
/**
 * set the sampling rate in Hz of this frame
 * @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
 */
private void setSamplingRate() throws InvalidAudioFrameException
{
    //Frequency
    int index = (mpegBytes[BYTE_3] & MASK_MP3_FREQUENCY) >>> 2;
    Map<Integer, Integer> samplingRateMapForVersion = samplingRateMap.get(version);
    if (samplingRateMapForVersion == null)
    {
        throw new InvalidAudioFrameException("Invalid version");
    }
    samplingRate = samplingRateMapForVersion.get(index);
    if (samplingRate == null)
    {
        throw new InvalidAudioFrameException("Invalid sampling rate");
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:20,代码来源:MPEGFrameHeader.java

示例7: MPEGFrameHeader

import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException; //导入依赖的package包/类
/**
 * Try and create a new MPEG frame with the given byte array and decodes its contents
 * If decoding header causes a problem it is not a valid header
 *
 * @param b the array of bytes representing this mpeg frame
 * @throws InvalidAudioFrameException if does not match expected format
 */
private MPEGFrameHeader(byte[] b) throws InvalidAudioFrameException
{
    mpegBytes = b;
    setBitrate();
    setVersion();
    setLayer();
    setProtected();
    setSamplingRate();
    setPadding();
    setPrivate();
    setChannelMode();
    setModeExtension();
    setCopyrighted();
    setOriginal();
    setEmphasis();
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:24,代码来源:MPEGFrameHeader.java

示例8: readFile

import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException; //导入依赖的package包/类
/**
 *
 * Read the tag contained in the given file.
 * 
 *
 * @param f The file to read.
 * @return The AudioFile with the file tag and the file encoding info.
 * @throws org.jaudiotagger.audio.exceptions.CannotReadException If the file could not be read, the extension wasn't
 *                             recognized, or an IO error occurred during the read.
 * @throws org.jaudiotagger.tag.TagException
 * @throws org.jaudiotagger.audio.exceptions.ReadOnlyFileException
 * @throws java.io.IOException
 * @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
 */
public AudioFile readFile(File f)
        throws CannotReadException, IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException
{
    checkFileExists(f);
    String ext = Utils.getExtension(f);

    AudioFileReader afr = readers.get(ext);
    if (afr == null)
    {
        throw new CannotReadException(ErrorMessage.NO_READER_FOR_THIS_FORMAT.getMsg(ext));
    }
    AudioFile tempFile = afr.read(f);
    tempFile.setExt(ext);
    return tempFile;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:30,代码来源:AudioFileIO.java

示例9: readFileMagic

import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException; //导入依赖的package包/类
/**
 *
 * Read the tag contained in the given file.
 * 
 *
 * @param f The file to read.
 * @return The AudioFile with the file tag and the file encoding info.
 * @throws org.jaudiotagger.audio.exceptions.CannotReadException If the file could not be read, the extension wasn't
 *                             recognized, or an IO error occurred during the read.
 * @throws org.jaudiotagger.tag.TagException
 * @throws org.jaudiotagger.audio.exceptions.ReadOnlyFileException
 * @throws java.io.IOException
 * @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
 */
public AudioFile readFileMagic(File f)
        throws CannotReadException, IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException
{
    checkFileExists(f);
    String ext = Utils.getMagicExtension(f);

    AudioFileReader afr = readers.get(ext);
    if (afr == null)
    {
        throw new CannotReadException(ErrorMessage.NO_READER_FOR_THIS_FORMAT.getMsg(ext));
    }

    AudioFile tempFile = afr.read(f);
    tempFile.setExt(ext);
    return tempFile;

}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:32,代码来源:AudioFileIO.java

示例10: readFileAs

import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException; //导入依赖的package包/类
/**
   *
   * Read the tag contained in the given file.
   * 
   *
   * @param f The file to read.
   * @param ext The extension to be used.
   * @return The AudioFile with the file tag and the file encoding info.
   * @throws org.jaudiotagger.audio.exceptions.CannotReadException If the file could not be read, the extension wasn't
   *                             recognized, or an IO error occurred during the read.
   * @throws org.jaudiotagger.tag.TagException
   * @throws org.jaudiotagger.audio.exceptions.ReadOnlyFileException
   * @throws java.io.IOException
   * @throws org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
   */
  public AudioFile readFileAs(File f,String ext)
          throws CannotReadException, IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException
  {
      checkFileExists(f);
//      String ext = Utils.getExtension(f);

      AudioFileReader afr = readers.get(ext);
      if (afr == null)
      {
          throw new CannotReadException(ErrorMessage.NO_READER_FOR_THIS_FORMAT.getMsg(ext));
      }

      AudioFile tempFile = afr.read(f);
      tempFile.setExt(ext);
      return tempFile;

  }
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:33,代码来源:AudioFileIO.java

示例11: insertLyrics

import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException; //导入依赖的package包/类
/**
 * Insert Lyrics
 *
 * @param path
 * @param lyrics
 * @return
 */
public static boolean insertLyrics(String path, String lyrics) {
    File f = new File(path);
    if (f.exists()) {
        try {
            AudioFile audioFile = AudioFileIO.read(f);
            if (audioFile == null) {
                return false;
            }
            TagOptionSingleton.getInstance().setAndroid(true);
            Tag tag = audioFile.getTag();
            if (tag == null) {
                return false;
            }
            tag.deleteField(FieldKey.LYRICS);
            tag.setField(FieldKey.LYRICS, lyrics);
            audioFile.setTag(tag);
            AudioFileIO.write(audioFile);
            return true;
        } catch (CannotReadException | CannotWriteException | InvalidAudioFrameException | TagException | IOException | ReadOnlyFileException e) {
            e.printStackTrace();
        }
    }
    return false;
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:32,代码来源:LyricsHelper.java

示例12: AiffFile

import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException; //导入依赖的package包/类
public AiffFile(File file, boolean readOnly)
        throws IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException {
    RandomAccessFile newFile = null;
    try {
        logger.setLevel(Level.FINEST);
        logger.fine("Called AiffFile constructor on " + file.getAbsolutePath());
        this.file = file;

        //Check File accessibility
        newFile = checkFilePermissions(file, readOnly);
        audioHeader = new AiffAudioHeader();
        //readTag();

    } finally {
        if (newFile != null) {
            newFile.close();
        }
    }
}
 
开发者ID:openaudible,项目名称:openaudible,代码行数:20,代码来源:AiffFile.java

示例13: isNextFrameValid

import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException; //导入依赖的package包/类
private boolean isNextFrameValid(ByteBuffer bb) {
    boolean result = false;
    int currentPosition = bb.position();

    bb.position(bb.position() + mp3FrameHeader.getFrameLength());
    if (MPEGFrameHeader.isMPEGFrame(bb)) {
        try {
            MPEGFrameHeader.parseMPEGHeader(bb);
            MP3AudioHeader.logger.finer("Check next frame confirms is an audio header ");
            result = true;
        } catch (InvalidAudioFrameException ex) {
            MP3AudioHeader.logger.finer("Check next frame has identified this is not an audio header");
            result = false;
        }
    }
    // Set back to the start of the previous frame
    bb.position(currentPosition);
    return result;
}
 
开发者ID:openaudible,项目名称:openaudible,代码行数:20,代码来源:ByteArrayMP3AudioHeader.java

示例14: MPEGFrameHeader

import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException; //导入依赖的package包/类
/**
 * Try and create a new MPEG frame with the given byte array and decodes its contents
 * If decoding header causes a problem it is not a valid header
 *
 * @param b the array of bytes representing this mpeg frame
 * @throws InvalidAudioFrameException if does not match expected format
 */
private MPEGFrameHeader(byte[] b) throws InvalidAudioFrameException {
    mpegBytes = b;
    setBitrate();
    setVersion();
    setLayer();
    setProtected();
    setSamplingRate();
    setPadding();
    setPrivate();
    setChannelMode();
    setModeExtension();
    setCopyrighted();
    setOriginal();
    setEmphasis();
}
 
开发者ID:openaudible,项目名称:openaudible,代码行数:23,代码来源:MPEGFrameHeader.java

示例15: getMP3StartByte

import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException; //导入依赖的package包/类
@SuppressWarnings("TryWithIdenticalCatches")
public long getMP3StartByte(File file) throws InvalidAudioFrameException, IOException {
    //noinspection CaughtExceptionImmediatelyRethrown,CaughtExceptionImmediatelyRethrown
    try {
        //Read ID3v2 tag size (if tag exists) to allow audio header parsing to skip over tag
        long startByte = AbstractID3v2Tag.getV2TagSizeIfExists(file);

        MP3AudioHeader audioHeader = new MP3AudioHeader(file, startByte);
        if (startByte != audioHeader.getMp3StartByte()) {
            logger.config("First header found after tag:" + audioHeader);
            audioHeader = checkAudioStart(startByte, audioHeader);
        }
        return audioHeader.getMp3StartByte();
    } catch (InvalidAudioFrameException iafe) {
        throw iafe;
    } catch (IOException ioe) {
        throw ioe;
    }
}
 
开发者ID:Old-Geek,项目名称:Musique,代码行数:20,代码来源:MP3File.java


注:本文中的org.jaudiotagger.audio.exceptions.InvalidAudioFrameException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。