org.red5.io.mp3.impl

## Class MP3Reader

- java.lang.Object
- - org.red5.io.mp3.impl.MP3Reader

All Implemented Interfaces:
  IKeyFrameDataAnalyzer, ITagReader

    public class MP3Reader
    extends Object
    implements ITagReader, IKeyFrameDataAnalyzer

Read MP3 files

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.red5.io.flv.IKeyFrameDataAnalyzer

`IKeyFrameDataAnalyzer.KeyFrameMeta`

### Field Summary

Fields
`protected static org.slf4j.Logger` `log` Logger

### Constructor Summary

Constructors
Constructor and Description
`MP3Reader(File file)` Creates reader from file input stream

### Method Summary

Methods
`IKeyFrameDataAnalyzer.KeyFrameMeta` `analyzeKeyFrames()` Analyze and return keyframe metadata.
`void` `close()` Closes the reader and free any allocated memory.
`void` `decodeHeader()` Decode the header of the stream;
`long` `getBytesRead()` Returns the amount of bytes read
`long` `getDuration()` Return length in seconds
`IStreamableFile` `getFile()` Return the file that is loaded.
`int` `getOffset()` Returns the offet length
`long` `getTotalBytes()` Get the total readable bytes in a file or ByteBuffer.
`boolean` `hasMoreTags()` Returns a boolean stating whether the FLV has more tags
`boolean` `hasVideo()` A MP3 stream never has video.
`void` `position(long pos)` Move the reader pointer to given position in file.
`ITag` `readTag()` Returns a Tag object
`void` `searchNextFrame()` Search for next frame sync word.
`void` `setFrameCache(IKeyFrameMetaCache frameCache)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### log

    protected static org.slf4j.Logger log

Logger

### Constructor Detail

#### MP3Reader

    public MP3Reader(File file)
              throws IOException

Creates reader from file input stream

Parameters:
  `file` - file input
Throws:
  `IOException`

### Method Detail

#### hasVideo

    public boolean hasVideo()

A MP3 stream never has video.

Specified by:
  `hasVideo` in interface `ITagReader`
Returns:
  always returns `false`

#### setFrameCache

    public void setFrameCache(IKeyFrameMetaCache frameCache)

#### searchNextFrame

    public void searchNextFrame()

Search for next frame sync word. Sync word identifies valid frame.

#### getFile

    public IStreamableFile getFile()

Return the file that is loaded.

Specified by:
  `getFile` in interface `ITagReader`
Returns:
  the file to be loaded

#### getOffset

    public int getOffset()

Returns the offet length

Specified by:
  `getOffset` in interface `ITagReader`
Returns:
  int

#### getBytesRead

    public long getBytesRead()

Returns the amount of bytes read

Specified by:
  `getBytesRead` in interface `ITagReader`
Returns:
  long

#### getDuration

    public long getDuration()

Return length in seconds

Specified by:
  `getDuration` in interface `ITagReader`
Returns:
  length in seconds

#### getTotalBytes

    public long getTotalBytes()

Get the total readable bytes in a file or ByteBuffer.

Specified by:
  `getTotalBytes` in interface `ITagReader`
Returns:
  Total readable bytes

#### hasMoreTags

    public boolean hasMoreTags()

Returns a boolean stating whether the FLV has more tags

Specified by:
  `hasMoreTags` in interface `ITagReader`
Returns:
  boolean

#### readTag

    public ITag readTag()

Returns a Tag object

Specified by:
  `readTag` in interface `ITagReader`
Returns:
  Tag

#### close

    public void close()

Closes the reader and free any allocated memory.

Specified by:
  `close` in interface `ITagReader`

#### decodeHeader

    public void decodeHeader()

Decode the header of the stream;

Specified by:
  `decodeHeader` in interface `ITagReader`

#### position

    public void position(long pos)

Move the reader pointer to given position in file.

Specified by:
  `position` in interface `ITagReader`
Parameters:
  `pos` - File position to move to

#### analyzeKeyFrames

    public IKeyFrameDataAnalyzer.KeyFrameMeta analyzeKeyFrames()

Analyze and return keyframe metadata.

Specified by:
  `analyzeKeyFrames` in interface `IKeyFrameDataAnalyzer`
Returns:
  Metadata object