Class Mp3TrackProvider

  • All Implemented Interfaces:
    AudioTrackInfoProvider

    public class Mp3TrackProvider
    extends java.lang.Object
    implements AudioTrackInfoProvider
    Handles parsing MP3 files, seeking and sending the decoded frames to the specified frame consumer.
    • Constructor Detail

      • Mp3TrackProvider

        public Mp3TrackProvider​(AudioProcessingContext context,
                                SeekableInputStream inputStream)
        Parameters:
        context - Configuration and output information for processing. May be null in case no frames are read and this instance is only used to retrieve information about the track.
        inputStream - Stream to read the file from
    • Method Detail

      • parseHeaders

        public void parseHeaders()
                          throws java.io.IOException
        Parses file headers to find the first MP3 frame and to get the settings for initialising the filter chain.
        Throws:
        java.io.IOException - On read error
      • provideFrames

        public void provideFrames()
                           throws java.lang.InterruptedException
        Decodes audio frames and sends them to frame consumer
        Throws:
        java.lang.InterruptedException - When interrupted externally (or for seek/stop).
      • seekToTimecode

        public void seekToTimecode​(long timecode)
        Seeks to the specified timecode.
        Parameters:
        timecode - The timecode in milliseconds
      • isSeekable

        public boolean isSeekable()
        Returns:
        True if the track is seekable (false for streams for example).
      • getDuration

        public long getDuration()
        Returns:
        An estimated duration of the file in milliseconds
      • getIdv3Tag

        public java.lang.String getIdv3Tag​(java.lang.String tagId)
        Gets an ID3 tag. These are loaded when parsing headers and only for a fixed list of tags.
        Parameters:
        tagId - The FourCC of the tag
        Returns:
        The value of the tag if present, otherwise null
      • close

        public void close()
        Closes resources.
      • getTitle

        public java.lang.String getTitle()
        Specified by:
        getTitle in interface AudioTrackInfoProvider
        Returns:
        Track title, or null if this provider does not know it.
      • getAuthor

        public java.lang.String getAuthor()
        Specified by:
        getAuthor in interface AudioTrackInfoProvider
        Returns:
        Track author, or null if this provider does not know it.
      • getLength

        public java.lang.Long getLength()
        Specified by:
        getLength in interface AudioTrackInfoProvider
        Returns:
        Track length in milliseconds, or null if this provider does not know it.
      • getIdentifier

        public java.lang.String getIdentifier()
        Specified by:
        getIdentifier in interface AudioTrackInfoProvider
        Returns:
        Track identifier, or null if this provider does not know it.
      • getUri

        public java.lang.String getUri()
        Specified by:
        getUri in interface AudioTrackInfoProvider
        Returns:
        Track URI, or null if this provider does not know it.