Documentation ¶
Index ¶
- func SetAlpha(a byte, data []byte)
- type ExpectedHeader
- type Player
- func (plm *Player) AudioEnabled() bool
- func (plm *Player) AudioLeadTime() time.Duration
- func (plm *Player) ByteDepth() int
- func (plm *Player) ClearAudioBuffer()
- func (plm *Player) Close()
- func (plm *Player) Decode(elapsed time.Duration)
- func (plm *Player) DrawFrameAt(img draw.Image, elapsed time.Duration, exact bool) bool
- func (plm *Player) DrawTo(img draw.Image)
- func (plm *Player) Duration() time.Duration
- func (plm *Player) Finished() bool
- func (plm *Player) FrameRate() float64
- func (plm *Player) HasAudio() bool
- func (plm *Player) HasNewAudio() bool
- func (plm *Player) HasNewFrame() bool
- func (plm *Player) HasVideo() bool
- func (plm *Player) Height() int
- func (plm *Player) Loop() bool
- func (plm *Player) NumAudioStreams() int
- func (plm *Player) NumVideoStreams() int
- func (plm *Player) Read(buf []byte) (n int, err error)
- func (plm *Player) ReadRGBA(data []byte)
- func (plm *Player) ReadRGBAAt(data []byte, elapsed time.Duration, exact bool) bool
- func (plm *Player) Rewind()
- func (plm *Player) SampleRate() int
- func (plm *Player) Seek(time time.Duration, exact bool) bool
- func (plm *Player) SetAudioEnabled(enabled bool)
- func (plm *Player) SetAudioLeadTime(time time.Duration)
- func (plm *Player) SetByteDepth(depth int)
- func (plm *Player) SetLoop(set bool)
- func (plm *Player) SetVideoEnabled(enabled bool)
- func (plm *Player) Time() time.Duration
- func (plm *Player) VideoEnabled() bool
- func (plm *Player) Width() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ExpectedHeader ¶
type ExpectedHeader struct{}
ExpectedHeader is returned by "NewPlayer" functions when a file could not be processed
func (ExpectedHeader) Error ¶
func (err ExpectedHeader) Error() string
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
Player processes and decodes video and audio in MPG format (MPEG1 video encoding and MP2 audio encoding)
func NewPlayerFromBytes ¶
NewPlayerFromBytes creates a new player from a list of raw bytes.
func NewPlayerFromFile ¶
NewPlayerFromFile creates a new player from a given file. The file is not closed when the player is closed.
func NewPlayerFromFilename ¶
NewPlayerFromFile creates a new player from a given filename.
func (*Player) AudioEnabled ¶
AudioEnabled returns true if decoding audio is enabled.
func (*Player) AudioLeadTime ¶
AudioLeadTime is how long the audio is decoded in advance or behind the video decode time.
func (*Player) ClearAudioBuffer ¶
func (plm *Player) ClearAudioBuffer()
ClearAudioBuffer clears the audio buffer.
func (*Player) Close ¶
func (plm *Player) Close()
Close closes the internal player and discards data.
func (*Player) DrawFrameAt ¶
DrawFrameAt seeks to the specified time and draws the current frame to the image in "img".
If "exact" is false, this will seek to the nearest intra frame. If "exact" is true, this will seek to the exact time. this can be slower as each frame since the last intra frame would need to be decoded.
DrawFrameAt returns true when successful.
func (*Player) Finished ¶
Finished returns true when the video has ended. This is always false when looping.
func (*Player) HasNewAudio ¶
HasNewAudio returns true if the audio buffer still contains unread data.
func (*Player) HasNewFrame ¶
HasNewFrame returns true if a new frame has been decoded. Drawing the current frame sets this to false
func (*Player) NumAudioStreams ¶
NumAudioStreams returns the number of audio channels that are present in the file. (0-4)
func (*Player) NumVideoStreams ¶
NumVideoStreams returns the number of video channels present in the file. (0-1)
func (*Player) Read ¶
Read consumes and reads data from the audio buffer. If the audio buffer does not have any audio, it sends 0 to buf until it is full.
This is intended to make it easy to create an Ebiten or Oto player straight from this *Player
func (*Player) ReadRGBA ¶
ReadRGBA overwrites the passed byte array in "data" in RGBA format. Intended for writing the current frame directly to "image.RGBA.Pix".
Alpha channels remain unchanged.
ReadRGBA panics if the size of data does not match the size of the frame (width * height * 4).
func (*Player) ReadRGBAAt ¶
ReadRGBAAt seeks to the specified time and overwrites the passed byte array in "data" in RGBA format. Intended mainly for writing the current frame directly to "image.RGBA.Pix".
If "exact" is false, this will seek to the nearest intra frame. If "exact" is true, this will seek to the exact time. this can be slower as each frame since the last intra frame would need to be decoded.
ReadRGBAAt returns true when successful.
Alpha channels remain unchanged.
ReadRGBAAt panics if the size of data does not match the size of the frame (width * height * 4).
func (*Player) SampleRate ¶
SampleRate is how many samples per second in the audio stream.
func (*Player) Seek ¶
Seek to the specified time.
If "exact" is false, this will seek to the nearest intra frame. If "exact" is true, this will seek to the exact time. this can be slower as each frame since the last intra frame would need to be decoded.
Seek returns true when successful.
func (*Player) SetAudioEnabled ¶
SetAudioEnabled sets whether audio should be decoded.
func (*Player) SetAudioLeadTime ¶
SetAudioLeadTime sets how long the audio is decoded in advance or behind the video decode time. this is typically set to the duration of the buffer of your audio API.
func (*Player) SetByteDepth ¶
SetByteDepth sets how many bytes per sample audio is decoded as. Currently the values 1 (8-bit), 2 (16-bit), and 4 (32-bit) are supported.
func (*Player) SetVideoEnabled ¶
SetVideoEnabled sets whether video should be decododed.
func (*Player) VideoEnabled ¶
VideoEnabled returns true if decoding video is enabled.