Class Mp3ConstantRateSeeker

  • All Implemented Interfaces:
    Mp3Seeker

    public class Mp3ConstantRateSeeker
    extends java.lang.Object
    implements Mp3Seeker
    MP3 seeking support for constant bitrate files or in cases where the variable bitrate format used by the file is not supported. In case the file is not actually CBR, this being used as a fallback may cause inaccurate seeking.
    • Method Detail

      • createFromFrame

        public static Mp3ConstantRateSeeker createFromFrame​(long firstFramePosition,
                                                            long contentLength,
                                                            byte[] frameBuffer)
        Parameters:
        firstFramePosition - Position of the first frame in the file
        contentLength - Total length of the file
        frameBuffer - Buffer of the first frame
        Returns:
        Constant rate seeker, will always succeed, never null.
      • isMetaFrame

        public static boolean isMetaFrame​(byte[] frameBuffer)
      • getDuration

        public long getDuration()
        Specified by:
        getDuration in interface Mp3Seeker
        Returns:
        The duration of the file in milliseconds. May be an estimate.
      • isSeekable

        public boolean isSeekable()
        Specified by:
        isSeekable in interface Mp3Seeker
        Returns:
        True if the track is seekable.
      • seekAndGetFrameIndex

        public long seekAndGetFrameIndex​(long timecode,
                                         SeekableInputStream inputStream)
                                  throws java.io.IOException
        Specified by:
        seekAndGetFrameIndex in interface Mp3Seeker
        Parameters:
        timecode - The timecode that the seek is requested to
        inputStream - The input stream to perform the seek on
        Returns:
        The index of the frame that the seek was performed to
        Throws:
        java.io.IOException - On IO error