Class Mp3TrackProvider
- java.lang.Object
-
- com.sedmelluq.discord.lavaplayer.container.mp3.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 Summary
Constructors Constructor Description Mp3TrackProvider(AudioProcessingContext context, SeekableInputStream inputStream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes resources.java.lang.StringgetArtworkUrl()java.lang.StringgetAuthor()longgetDuration()java.lang.StringgetIdentifier()java.lang.StringgetIdv3Tag(java.lang.String tagId)Gets an ID3 tag.java.lang.StringgetISRC()java.lang.LonggetLength()java.lang.StringgetTitle()java.lang.StringgetUri()booleanisSeekable()voidparseHeaders()Parses file headers to find the first MP3 frame and to get the settings for initialising the filter chain.voidprovideFrames()Decodes audio frames and sends them to frame consumervoidseekToTimecode(long timecode)Seeks to the specified timecode.
-
-
-
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.IOExceptionParses 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.InterruptedExceptionDecodes 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:
getTitlein interfaceAudioTrackInfoProvider- Returns:
- Track title, or
nullif this provider does not know it.
-
getAuthor
public java.lang.String getAuthor()
- Specified by:
getAuthorin interfaceAudioTrackInfoProvider- Returns:
- Track author, or
nullif this provider does not know it.
-
getLength
public java.lang.Long getLength()
- Specified by:
getLengthin interfaceAudioTrackInfoProvider- Returns:
- Track length in milliseconds, or
nullif this provider does not know it.
-
getIdentifier
public java.lang.String getIdentifier()
- Specified by:
getIdentifierin interfaceAudioTrackInfoProvider- Returns:
- Track identifier, or
nullif this provider does not know it.
-
getUri
public java.lang.String getUri()
- Specified by:
getUriin interfaceAudioTrackInfoProvider- Returns:
- Track URI, or
nullif this provider does not know it.
-
getArtworkUrl
public java.lang.String getArtworkUrl()
- Specified by:
getArtworkUrlin interfaceAudioTrackInfoProvider
-
getISRC
public java.lang.String getISRC()
- Specified by:
getISRCin interfaceAudioTrackInfoProvider
-
-