Documentation
¶
Overview ¶
Package mpv provides cgo bindings for libmpv.
Index ¶
- Constants
- Variables
- func SetLocale(category int, locale string) string
- type Event
- type EventEndFile
- type EventID
- type EventLogMessage
- type EventProperty
- type EventStartFile
- type Format
- type Hook
- type Mpv
- func (m *Mpv) APIVersion() uint64
- func (m *Mpv) AbortAsyncCommand(replyUserdata uint64)
- func (m *Mpv) Command(cmd []string) error
- func (m *Mpv) CommandAsync(replyUserdata uint64, cmd []string) error
- func (m *Mpv) CommandNode(args interface{}) (interface{}, error)
- func (m *Mpv) CommandNodeAsync(replyUserdata uint64, args interface{}) error
- func (m *Mpv) CommandRet(cmd []string) (interface{}, error)
- func (m *Mpv) CommandString(cmd string) error
- func (m *Mpv) DelProperty(name string) error
- func (m *Mpv) Destroy()
- func (m *Mpv) GetProperty(name string, format Format) (interface{}, error)
- func (m *Mpv) GetPropertyAsync(name string, replyUserdata uint64, format Format) error
- func (m *Mpv) GetPropertyOsdString(name string) string
- func (m *Mpv) GetPropertyString(name string) string
- func (m *Mpv) HookAdd(replyUserdata uint64, name string, priority int) error
- func (m *Mpv) HookContinue(id uint64) error
- func (m *Mpv) ID() int64
- func (m *Mpv) Initialize() error
- func (m *Mpv) LoadConfigFile(fileName string) error
- func (m *Mpv) Name() string
- func (m *Mpv) NewRenderContextGL(getProcAddress func(name string) unsafe.Pointer) (*RenderContext, error)
- func (m *Mpv) NewRenderContextSW() (*RenderContext, error)
- func (m *Mpv) ObserveProperty(replyUserdata uint64, name string, format Format) error
- func (m *Mpv) RequestEvent(event EventID, enable bool) error
- func (m *Mpv) RequestLogMessages(level string) error
- func (m *Mpv) SetOption(name string, format Format, data interface{}) error
- func (m *Mpv) SetOptionString(name, value string) error
- func (m *Mpv) SetProperty(name string, format Format, data interface{}) error
- func (m *Mpv) SetPropertyAsync(name string, replyUserdata uint64, format Format, data interface{}) error
- func (m *Mpv) SetPropertyString(name, value string) error
- func (m *Mpv) TerminateDestroy()
- func (m *Mpv) TimeNS() int64
- func (m *Mpv) TimeUS() int64
- func (m *Mpv) UnobserveProperty(replyUserdata uint64) error
- func (m *Mpv) WaitAsyncRequests()
- func (m *Mpv) WaitEvent(timeout float64) *Event
- func (m *Mpv) Wakeup()
- func (m *Mpv) WakeupPipe() int
- type Reason
- type RenderContext
- func (rc *RenderContext) Free()
- func (rc *RenderContext) RenderGL(fbo, width, height int, flipY bool) error
- func (rc *RenderContext) RenderSW(width, height, stride int, format string, buf []byte) error
- func (rc *RenderContext) ReportSwap()
- func (rc *RenderContext) SetUpdateCallback(fn func())
- func (rc *RenderContext) Update() uint64
Constants ¶
const ( LCAll = C.LC_ALL LCNumeric = C.LC_NUMERIC )
Locale categories for SetLocale.
const ( RenderAPITypeOpenGL = "opengl" RenderAPITypeSW = "sw" )
Render API type strings for MPV_RENDER_PARAM_API_TYPE.
const RenderUpdateFrame uint64 = 1 << 0
RenderUpdateFrame is set in the result of RenderContext.Update when a new video frame should be rendered.
Variables ¶
var ErrAoInitFailed = errors.New("audio output initialization failed")
var ErrCommand = errors.New("error running command")
var ErrEventQueueFull = errors.New("event queue full")
var ErrGeneric = errors.New("something happened")
var ErrInvalidParameter = errors.New("invalid parameter")
var ErrLoadingFailed = errors.New("loading failed")
var ErrNomem = errors.New("memory allocation failed")
var ErrNotImplemented = errors.New("operation not implemented")
var ErrNothingToPlay = errors.New("no audio or video data played")
var ErrOptionError = errors.New("error setting option")
var ErrOptionFormat = errors.New("unsupported format for accessing option")
var ErrOptionNotFound = errors.New("option not found")
var ErrPropertyError = errors.New("error accessing property")
var ErrPropertyFormat = errors.New("unsupported format for accessing property")
var ErrPropertyNotFound = errors.New("property not found")
var ErrUninitialized = errors.New("core not uninitialized")
var ErrUnknown = errors.New("unknown error")
var ErrUnknownFormat = errors.New("unrecognized file format")
var ErrUnsupported = errors.New("not supported")
var ErrVoInitFailed = errors.New("video output initialization failed")
Functions ¶
Types ¶
type Event ¶
Event represents an mpv_event struct.
func (*Event) ClientMessage ¶ added in v0.3.0
ClientMessage returns the arguments of a client message event.
func (*Event) CommandReply ¶ added in v0.3.0
CommandReply returns the result of an asynchronous command.
func (*Event) Hook ¶ added in v0.3.0
Hook returns the hook event. Its ID must be passed to HookContinue.
func (*Event) LogMessage ¶
func (e *Event) LogMessage() EventLogMessage
LogMessage returns EventLogMessage.
func (*Event) StartFile ¶
func (e *Event) StartFile() EventStartFile
StartFile returns EventStartFile.
type EventEndFile ¶
type EventEndFile struct {
Reason Reason
Error error
EntryID int64
InsertID int64
InsertNumEntries int32
}
EventEndFile type.
type EventID ¶
type EventID uint32
EventID type.
const ( EventNone EventID = 0 EventShutdown EventID = 1 EventLogMsg EventID = 2 EventGetPropertyReply EventID = 3 EventSetPropertyReply EventID = 4 EventCommandReply EventID = 5 EventStart EventID = 6 EventEnd EventID = 7 EventFileLoaded EventID = 8 EventClientMessage EventID = 16 EventVideoReconfig EventID = 17 EventAudioReconfig EventID = 18 EventSeek EventID = 20 EventPlaybackRestart EventID = 21 EventPropertyChange EventID = 22 EventQueueOverflow EventID = 24 EventHook EventID = 25 )
EventID constants.
type EventLogMessage ¶
EventLogMessage type.
type EventProperty ¶
EventProperty type.
type Mpv ¶
type Mpv struct {
// contains filtered or unexported fields
}
Mpv represents an mpv client.
func New ¶ added in v0.2.0
func New() *Mpv
New creates a new mpv instance and an associated client API handle.
func (*Mpv) APIVersion ¶ added in v0.2.0
APIVersion returns the client api version the mpv source has been compiled with.
func (*Mpv) AbortAsyncCommand ¶ added in v0.3.0
AbortAsyncCommand aborts an outstanding asynchronous command with the given reply userdata.
func (*Mpv) Command ¶
Command runs the specified command, returning an error if something goes wrong.
func (*Mpv) CommandAsync ¶
CommandAsync runs the command asynchronously.
func (*Mpv) CommandNode ¶ added in v0.3.0
CommandNode runs a command given as a []any or map[string]any and returns its result.
func (*Mpv) CommandNodeAsync ¶ added in v0.3.0
CommandNodeAsync runs a structured command asynchronously.
func (*Mpv) CommandRet ¶ added in v0.3.0
CommandRet runs the specified command and returns its result.
func (*Mpv) CommandString ¶
CommandString runs the given command string, this string is parsed internally by mpv.
func (*Mpv) DelProperty ¶ added in v0.3.0
DelProperty deletes the given property.
func (*Mpv) Destroy ¶ added in v0.3.0
func (m *Mpv) Destroy()
Destroy disconnects and destroys this client handle without terminating mpv.
func (*Mpv) GetProperty ¶
GetProperty returns the value of the property according to the given format.
func (*Mpv) GetPropertyAsync ¶
GetPropertyAsync gets a property asynchronously.
func (*Mpv) GetPropertyOsdString ¶
GetPropertyOsdString returns the value of the property as a string formatted for on-screen display.
func (*Mpv) GetPropertyString ¶
GetPropertyString returns the value of the property as a string. If the property is empty, an empty string is returned.
func (*Mpv) HookAdd ¶ added in v0.3.0
HookAdd registers a hook handler for the named hook. Higher priority runs first.
func (*Mpv) HookContinue ¶ added in v0.3.0
HookContinue continues the hook with the given ID from a hook event.
func (*Mpv) Initialize ¶
Initialize initializes an uninitialized mpv instance.
func (*Mpv) LoadConfigFile ¶
LoadConfigFile loads the given config file.
func (*Mpv) NewRenderContextGL ¶ added in v0.4.0
func (m *Mpv) NewRenderContextGL(getProcAddress func(name string) unsafe.Pointer) (*RenderContext, error)
NewRenderContextGL creates an OpenGL render context; getProcAddress resolves GL functions. Requires vo=libmpv and the GL context current on the calling thread.
func (*Mpv) NewRenderContextSW ¶ added in v0.4.0
func (m *Mpv) NewRenderContextSW() (*RenderContext, error)
NewRenderContextSW creates a software (CPU) render context. The mpv instance must have the "vo" option set to "libmpv".
func (*Mpv) ObserveProperty ¶
ObserveProperty gets a notification whenever the given property changes.
func (*Mpv) RequestEvent ¶
RequestEvent enables or disables the given event.
func (*Mpv) RequestLogMessages ¶
RequestLogMessages enables or disables receiving of log messages. Valid log levels: no fatal error warn info v debug trace.
func (*Mpv) SetOptionString ¶
SetOptionString sets the option to the given string.
func (*Mpv) SetProperty ¶
SetProperty sets the client property according to the given format.
func (*Mpv) SetPropertyAsync ¶
func (m *Mpv) SetPropertyAsync(name string, replyUserdata uint64, format Format, data interface{}) error
SetPropertyAsync sets a property asynchronously.
func (*Mpv) SetPropertyString ¶
SetPropertyString sets the property to the given string.
func (*Mpv) TerminateDestroy ¶
func (m *Mpv) TerminateDestroy()
TerminateDestroy terminates mpv and destroys the client.
func (*Mpv) UnobserveProperty ¶
UnobserveProperty will remove all observed properties for passed replyUserdata.
func (*Mpv) WaitAsyncRequests ¶
func (m *Mpv) WaitAsyncRequests()
WaitAsyncRequests blocks until all asynchronous requests are done.
func (*Mpv) WakeupPipe ¶ added in v0.3.0
WakeupPipe returns the read end of a pipe that signals new events, or -1 on error.
type Reason ¶
type Reason uint32
Reason is end file reason.
type RenderContext ¶ added in v0.4.0
type RenderContext struct {
// contains filtered or unexported fields
}
RenderContext represents an mpv render context (the main video output).
func (*RenderContext) Free ¶ added in v0.4.0
func (rc *RenderContext) Free()
Free destroys the render context. Call it before the mpv core is destroyed.
func (*RenderContext) RenderGL ¶ added in v0.4.0
func (rc *RenderContext) RenderGL(fbo, width, height int, flipY bool) error
RenderGL renders the current frame into the given OpenGL framebuffer object (0 for the default framebuffer). Set flipY for bottom-up coordinate systems.
func (*RenderContext) RenderSW ¶ added in v0.4.0
func (rc *RenderContext) RenderSW(width, height, stride int, format string, buf []byte) error
RenderSW renders the current frame into buf, which must hold stride*height bytes. format is one of "rgb0", "bgr0", "0bgr", "0rgb".
func (*RenderContext) ReportSwap ¶ added in v0.4.0
func (rc *RenderContext) ReportSwap()
ReportSwap tells mpv that a frame swap (vsync) occurred.
func (*RenderContext) SetUpdateCallback ¶ added in v0.4.0
func (rc *RenderContext) SetUpdateCallback(fn func())
SetUpdateCallback sets fn to run when a new frame is ready. fn runs on an mpv thread and must only signal a redraw, not call mpv or render directly.
func (*RenderContext) Update ¶ added in v0.4.0
func (rc *RenderContext) Update() uint64
Update returns the render update flags; check the result against RenderUpdateFrame.