mpv

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2024 License: GPL-3.0 Imports: 4 Imported by: 7

README

go-mpv

Build Status Go Reference

Go bindings for libmpv.

Build tags

  • nocgo - use purego implementation (can also be used with CGO_ENABLED=0)
  • pkgconfig - use pkg-config
  • static - use static library (used with pkgconfig)

Documentation

Overview

Package mpv provides cgo bindings for libmpv.

Index

Constants

This section is empty.

Variables

View Source
var ErrAoInitFailed = errors.New("audio output initialization failed")
View Source
var ErrCommand = errors.New("error running command")
View Source
var ErrEventQueueFull = errors.New("event queue full")
View Source
var ErrGeneric = errors.New("something happened")
View Source
var ErrInvalidParameter = errors.New("invalid parameter")
View Source
var ErrLoadingFailed = errors.New("loading failed")
View Source
var ErrNomem = errors.New("memory allocation failed")
View Source
var ErrNotImplemented = errors.New("operation not implemented")
View Source
var ErrNothingToPlay = errors.New("no audio or video data played")
View Source
var ErrOptionError = errors.New("error setting option")
View Source
var ErrOptionFormat = errors.New("unsupported format for accessing option")
View Source
var ErrOptionNotFound = errors.New("option not found")
View Source
var ErrPropertyError = errors.New("error accessing property")
View Source
var ErrPropertyFormat = errors.New("unsupported format for accessing property")
View Source
var ErrPropertyNotFound = errors.New("property not found")
View Source
var ErrPropertyUnavailable = errors.New("property unavailable")
View Source
var ErrUninitialized = errors.New("core not uninitialized")
View Source
var ErrUnknown = errors.New("unknown error")
View Source
var ErrUnknownFormat = errors.New("unrecognized file format")
View Source
var ErrUnsupported = errors.New("not supported")
View Source
var ErrVoInitFailed = errors.New("video output initialization failed")

Functions

This section is empty.

Types

type Event

type Event struct {
	EventID       EventID
	Error         error
	ReplyUserdata uint64
	Data          unsafe.Pointer
}

Event represents an mpv_event struct.

func (*Event) EndFile

func (e *Event) EndFile() EventEndFile

EndFile returns EventEndFile.

func (*Event) LogMessage

func (e *Event) LogMessage() EventLogMessage

LogMessage returns EventLogMessage.

func (*Event) Property

func (e *Event) Property() EventProperty

Property returns EventProperty.

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.

func (EventID) String

func (e EventID) String() string

String .

type EventLogMessage

type EventLogMessage struct {
	Prefix   string
	Level    string
	Text     string
	LogLevel uint32
}

EventLogMessage type.

type EventProperty

type EventProperty struct {
	Name   string
	Format Format
	Data   any
}

EventProperty type.

type EventStartFile

type EventStartFile struct {
	EntryID int64
}

EventStartFile type.

type Format

type Format uint32

Format is data format for options and properties.

const (
	FormatNone Format = iota
	FormatString
	FormatOsdString
	FormatFlag
	FormatInt64
	FormatDouble
)

Data formats.

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

func (m *Mpv) APIVersion() uint64

APIVersion returns the client api version the mpv source has been compiled with.

func (*Mpv) Command

func (m *Mpv) Command(cmd []string) error

Command runs the specified command, returning an error if something goes wrong.

func (*Mpv) CommandAsync

func (m *Mpv) CommandAsync(replyUserdata uint64, cmd []string) error

CommandAsync runs the command asynchronously.

func (*Mpv) CommandString

func (m *Mpv) CommandString(cmd string) error

CommandString runs the given command string, this string is parsed internally by mpv.

func (*Mpv) GetProperty

func (m *Mpv) GetProperty(name string, format Format) (interface{}, error)

GetProperty returns the value of the property according to the given format.

func (*Mpv) GetPropertyAsync

func (m *Mpv) GetPropertyAsync(name string, replyUserdata uint64, format Format) error

GetPropertyAsync gets a property asynchronously.

func (*Mpv) GetPropertyOsdString

func (m *Mpv) GetPropertyOsdString(name string) string

GetPropertyOsdString returns the value of the property as a string formatted for on-screen display.

func (*Mpv) GetPropertyString

func (m *Mpv) GetPropertyString(name string) string

GetPropertyString returns the value of the property as a string. If the property is empty, an empty string is returned.

func (*Mpv) ID

func (m *Mpv) ID() int64

ID returns the ID of this client handle.

func (*Mpv) Initialize

func (m *Mpv) Initialize() error

Initialize initializes an uninitialized mpv instance.

func (*Mpv) LoadConfigFile

func (m *Mpv) LoadConfigFile(fileName string) error

LoadConfigFile loads the given config file.

func (*Mpv) Name

func (m *Mpv) Name() string

Name returns the name of this client handle.

func (*Mpv) ObserveProperty

func (m *Mpv) ObserveProperty(replyUserdata uint64, name string, format Format) error

ObserveProperty gets a notification whenever the given property changes.

func (*Mpv) RequestEvent

func (m *Mpv) RequestEvent(event EventID, enable bool) error

RequestEvent enables or disables the given event.

func (*Mpv) RequestLogMessages

func (m *Mpv) RequestLogMessages(level string) error

RequestLogMessages enables or disables receiving of log messages. Valid log levels: no fatal error warn info v debug trace.

func (*Mpv) SetOption

func (m *Mpv) SetOption(name string, format Format, data interface{}) error

SetOption sets the given option according to the given format.

func (*Mpv) SetOptionString

func (m *Mpv) SetOptionString(name, value string) error

SetOptionString sets the option to the given string.

func (*Mpv) SetProperty

func (m *Mpv) SetProperty(name string, format Format, data interface{}) error

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

func (m *Mpv) SetPropertyString(name, value string) error

SetPropertyString sets the property to the given string.

func (*Mpv) TerminateDestroy

func (m *Mpv) TerminateDestroy()

TerminateDestroy terminates mpv and destroys the client.

func (*Mpv) TimeUS

func (m *Mpv) TimeUS() int64

TimeUS returns the internal time in microseconds.

func (*Mpv) UnobserveProperty

func (m *Mpv) UnobserveProperty(replyUserdata uint64) error

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) WaitEvent

func (m *Mpv) WaitEvent(timeout float64) *Event

WaitEvent calls mpv_wait_event and returns the result as an Event struct.

func (*Mpv) Wakeup

func (m *Mpv) Wakeup()

Wakeup interrupts the current mpv_wait_event() call.

type Reason

type Reason uint32

Reason is end file reason.

const (
	EndFileEOF      Reason = 0
	EndFileStop     Reason = 2
	EndFileQuit     Reason = 3
	EndFileError    Reason = 4
	EndFileRedirect Reason = 5
)

End file reasons.

func (Reason) String

func (r Reason) String() string

String .

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL