Documentation
¶
Overview ¶
Package player plays goav media in a window, with pure-Go windowing and audio output (Ebitengine and oto: no cgo on macOS, Windows, or Linux).
The speaker is the master clock. Its played position is the clock the whole task runs on (runconfig.WithClock), so the realtime pacer delivers media exactly as fast as it is heard; video is presented against the heard audio position, late frames are dropped, early ones waited for. Pause, seek, and rate are the task's own controls.
w := player.New(player.Title("demo"))
rt := bundle.MustNew(w.RuntimeOption())
in := goav.Read("in.webm", f)
task, err := rt.Build(ctx,
in.Video().Decode().To(w.Destination()),
in.Audio().Decode().Resample(48000, 2).To(w.Destination()))
...
err = w.Run(ctx, task) // on the main goroutine
In a launch program the window is the play element (Window.Element): goav run 'file in.webm ! video ! decode ! play; file in.webm ! audio ! decode ! play'.
On Linux the window and the speaker load libX11/libGL and PulseAudio or libasound at run time; without an audio device playback continues silently on a free-running clock.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Window)
Option configures a Window.
func Latency ¶
Latency sets how much audio is buffered before playback starts and after a seek (default 200ms): more absorbs decode hiccups, less starts sooner.
type Stats ¶
type Stats struct {
// Position is the media time being heard (without audio: shown).
Position time.Duration
// Presented and Dropped count video frames shown and discarded late.
Presented, Dropped uint64
// Underruns counts times the audio queue ran dry mid-playback.
Underruns uint64
// AVOffset is the heard position minus the last shown frame's time
// (positive: the picture was late); MaxAVOffset is the largest magnitude.
AVOffset, MaxAVOffset time.Duration
}
Stats is a point-in-time view of playback.
type Task ¶
type Task interface {
Run(context.Context) error
Close() error
Pause(context.Context) error
Resume(context.Context) error
Control(context.Context, control.Control) error
}
Task is the narrow view of a *goav.Task that a playback Window drives.
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window is a playback window and the speaker it plays through. Its Destination takes decoded video and audio; its Clock is the speaker's hardware clock, which the task should run on; Run shows the window.
func New ¶
New prepares a window. Nothing opens until Run: building the task first is free, and a program that never routes to the window costs nothing.
func (*Window) Clock ¶
Clock is the speaker's clock. Build the runtime with runconfig.WithClock(w.Clock()) and runconfig.WithRealtime(true) so the task timeline runs in the speaker's time: media is then delivered exactly as fast as it is heard, and the task's Pause, Rate, and Seek drive playback.
func (*Window) Destination ¶
func (w *Window) Destination() goav.Destination
Destination is the window as a goav destination: route decoded video and decoded audio to the same value and they play together. Audio of any rate and channel count is accepted (s16 or f32, interleaved); .Resample(48000, 2) before it gives the best quality.
func (*Window) Element ¶
Element is the launch element "play [title=T] [size=WxH]": a destination that plays what reaches it in this window. Every use in a program is the same window, so video and audio statements ending in play play together.
func (*Window) Run ¶
Run opens the speaker and the window, runs task, and returns when the media has played out, the window is closed, or ctx ends; closing the window closes the task. Space pauses, the arrows seek (←/→ 5s, ↓/↑ 30s), [ and ] change the rate, f toggles full screen, i the overlay, and q or Esc quits — all through the task's own Pause, Resume, and Control.
Run must be called from the main goroutine (the windowing systems require it) and at most once per process (one audio device context per process).
func (*Window) RuntimeOption ¶
RuntimeOption returns a single runtime option that paces a task against this window's hardware speaker clock in realtime mode:
rt := bundle.MustNew(w.RuntimeOption())
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
engine
Package engine is the player's media core, free of any window or audio backend: the audio renderer the device pulls from, the device clock, the audio-mastered video presenter, the goav sink that feeds them, and the Y'CbCr conversion.
|
Package engine is the player's media core, free of any window or audio backend: the audio renderer the device pulls from, the device clock, the audio-mastered video presenter, the goav sink that feeds them, and the Y'CbCr conversion. |