Package mp3 provides MP3 decoder.

On desktops and mobiles, a pure Go decoder is used. On browsers, a native decoder on the browser is used.



This section is empty.


This section is empty.


This section is empty.


type Stream

type Stream struct {

	// contains filtered or unexported fields


Stream is a decoded stream.

func Decode

func Decode(context *audio.Context, src io.ReadSeeker) (*Stream, error)

Decode decodes MP3 source and returns a decoded stream.

Decode returns error when decoding fails or IO error happens.

Decode automatically resamples the stream to fit with the audio context if necessary.

A Stream doesn't close src even if src implements io.Closer. Closing the source is src owner's responsibility.

func (*Stream) Length

func (s *Stream) Length() int64

Length returns the size of decoded stream in bytes.

func (*Stream) Read

func (s *Stream) Read(buf []byte) (int, error)

Read is implementation of io.Reader's Read.

func (*Stream) Seek

func (s *Stream) Seek(offset int64, whence int) (int64, error)

Seek is implementation of io.Seeker's Seek.

Source Files