Documentation ¶
Overview ¶
Package xmms2Go is a Go binding for libxmmsclient. It's easy to use and friendly for go developers. Just import me to use.
package main import( "github.com/tonychee7000/xmms2go" "os" "fmt" ) func main(){ x := xmms2go.NewXmms2Client("test") err := x.Connect(os.Getenv("XMMS_PATH")) // According to the documents of xmms2, some resources // should be released. So Unref() is necessary. defer x.Unref() if err != nil { fmt.Println(err) os.Exit(1) } err := x.Play() if err != nil { fmt.Println(err) } }
Index ¶
- Constants
- func GetUserConfDir(b []byte) string
- type BitBuffer
- type BitBufferReadonly
- type Collection
- type Connector
- func (c *Connector) BroadCastQuit() *Result
- func (c *Connector) Connect(url string) error
- func (c *Connector) DisconnectCallBackSet(disconnectfunc DisconnectFunc, userdata interface{})
- func (c *Connector) DisconnectCallBackSetFull(disconnectfunc DisconnectFunc, userdata interface{}, ...)
- func (c *Connector) GetLastError() error
- func (c *Connector) IODisconnect()
- func (c *Connector) IOFdGet() error
- func (c *Connector) IOInHandle() error
- func (c *Connector) IONeedOutCallbackSet(ioneedoutcallback IONeedOutCallbackFunc, userdata interface{})
- func (c *Connector) IONeedOutCallbackSetFull(ioneedoutcallback IONeedOutCallbackFunc, userdata interface{}, ...)
- func (c *Connector) IOOutHandle() error
- func (c *Connector) IOWantOut() error
- func (c *Connector) LockSet(lock interface{}, lockfunc LockFunc, unlockfunc UnlockFunc)
- func (c *Connector) Quit() *Result
- func (c *Connector) UnRef()
- type Dict
- type DictIter
- func (i *DictIter) Destroy()
- func (i *DictIter) Find(key string) error
- func (i *DictIter) First()
- func (i *DictIter) GetFloat32() (string, float32, error)
- func (i *DictIter) GetFloat64() (string, float64, error)
- func (i *DictIter) Next()
- func (i *DictIter) Pair() (string, *Value, error)
- func (i *DictIter) PairInt32() (string, int32, error)
- func (i *DictIter) PairInt64() (string, int64, error)
- func (i *DictIter) PairString() (string, string, error)
- func (i *DictIter) Remove() error
- func (i *DictIter) Set(val *Value) error
- func (i *DictIter) SetFloat32(val float32) error
- func (i *DictIter) SetFloat64(val float64) error
- func (i *DictIter) SetInt32(val int32) error
- func (i *DictIter) SetInt64(val int64) error
- func (i *DictIter) SetString(s string) error
- func (i *DictIter) Valid() bool
- type DisconnectFunc
- type IONeedOutCallbackFunc
- type List
- type ListCompareFunc
- type ListIter
- func (l *ListIter) Destroy()
- func (l *ListIter) Entry() (*Value, error)
- func (l *ListIter) EntryFloat32() (float32, error)
- func (l *ListIter) EntryFloat64() (float64, error)
- func (l *ListIter) EntryInt32() (int32, error)
- func (l *ListIter) EntryInt64() (int64, error)
- func (l *ListIter) EntryString() (string, error)
- func (l *ListIter) First()
- func (l *ListIter) GetParent() *Value
- func (l *ListIter) Insert(val *Value) error
- func (l *ListIter) InsertFloat32(f float32) error
- func (l *ListIter) InsertFloat64(f float64) error
- func (l *ListIter) InsertInt32(i int32) error
- func (l *ListIter) InsertInt64(i int64) error
- func (l *ListIter) InsertString(s string) error
- func (l *ListIter) Last()
- func (l *ListIter) Next()
- func (l *ListIter) Prev()
- func (l *ListIter) Remove() error
- func (l *ListIter) Seek(pos int) error
- func (l *ListIter) Set(val *Value) error
- func (l *ListIter) Tell() int
- func (l *ListIter) Valid() bool
- type LockFunc
- type Result
- func (r *Result) Disconnect()
- func (r *Result) GetClass() int
- func (r *Result) GetValue() *Value
- func (r *Result) NotifierSetC2C()
- func (r *Result) NotifierSetC2CFull()
- func (r *Result) NotifierSetDefault()
- func (r *Result) NotifierSetDefaultFull()
- func (r *Result) NotifierSetRaw()
- func (r *Result) NotifierSetRawFull()
- func (r *Result) UnRef()
- func (r *Result) Wait()
- type UnlockFunc
- type UserDataFreeFunc
- type Value
- func (x *Value) GetAny() (interface{}, error)
- func (x *Value) GetBitBuffer() (BitBuffer, error)
- func (x *Value) GetBytes() ([]byte, error)
- func (x *Value) GetCollection() (Collection, error)
- func (x *Value) GetDict() (Dict, error)
- func (x *Value) GetError() (error, error)
- func (x *Value) GetFloat32() (float32, error)
- func (x *Value) GetFloat64() (float64, error)
- func (x *Value) GetInt32() (int32, error)
- func (x *Value) GetInt64() (int64, error)
- func (x *Value) GetList() (List, error)
- func (x *Value) GetString() (string, error)
- func (x *Value) GetType() int
- func (x *Value) IsError() bool
- func (x *Value) IsType(t int) bool
- func (x *Value) ToValue() *Value
- func (x *Value) Unref()
- type ValueAny
- type ValueBytes
- type ValueError
- type ValueFloat32
- type ValueFloat64
- type ValueInt32
- type ValueInt64
- type ValueNone
- type ValueString
- type Xmms2Client
- func (x *Xmms2Client) Connect(url string) error
- func (x *Xmms2Client) CurrentID() (int, error)
- func (x *Xmms2Client) MediaLibInfo(id int) (map[string]interface{}, error)
- func (x *Xmms2Client) Pause() error
- func (x *Xmms2Client) Play() error
- func (x *Xmms2Client) ResultUnref()
- func (x *Xmms2Client) Stop() error
- func (x *Xmms2Client) Tickle() error
- func (x *Xmms2Client) Unref()
Constants ¶
const ( IPCObjectSignal = iota IPCObjectMain IPCObjectPlaylist IPCObjectConfig IPCObjectPlayback IPCObjectMedialib IPCObjectCollection IPCObjectVisualization IPCObjectMediaInfoReader IPCObjectXform IPCObjectBindata IPCObjectCollSync IPCObjectCourier IPCObjectIPCManager IPCObjectEnd )
IPC object type
const ( IPCSignalPlaylistChanged = iota IPCSignalConfigValueChanged IPCSignalPlaybackStatus IPCSignalPlaybackVolumeChanged IPCSignalPlaybackPlaytime IPCSignalPlaybackCurrentID IPCSignalPlaylistCurrentPos IPCSignalPlaylistLoaded IPCSignalMedialibEntryAdded IPCSignalMedialibEntryUpdate IPCSignalMedialibEntryRemoved IPCSignalCollectionChanged IPCSignalQuit IPCSignalMediaInfoReaderStstus IPCSignalMediaInfoReaderUnindexed IPCSignalCourierMessage IPCSignalIPCManagerClientConnected IPCSignalIPCManagerClientDisconnected IPCSignalEnd )
IPC signals
const ( IPCCmdReply = iota IPCCmdError )
IPC command reply
const ( IPCCmdSignal = ipcCmdFirst + iota IPCCmdBroadcast )
Signal subsystem methods
const ( IPCCmdHello = ipcCmdFirst + iota IPCCmdQuit IPCCmdPluginList IPCCmdStats )
Main methods
const ( IPCCmdReplace = ipcCmdFirst + iota IPCCmdSetpOS IPCCmdSetpOSRel IPCCmdAddURL IPCCmdAddColl IPCCmdRemoveEntry IPCCmdMoveEntry IPCCmdList IPCCmdCurrentPos IPCCmdCurrentActive IPCCmdInsertURL IPCCmdInsertColl IPCCmdLoad IPCCmdRAdd IPCCmdRInsert )
Playlist methods
const ( IPCCmdGetValue = ipcCmdFirst + iota IPCCmdSetValue IPCCmdRegValue IPCCmdListValues )
Config methods
const ( IPCCmdStart = ipcCmdFirst + iota IPCCmdStop IPCCmdPausE IPCCmdDecoderKill IPCCmdCPlaytime IPCCmdSeekMS IPCCmdSeekSamples IPCCmdPlaybackStatus IPCCmdCurrentID IPCCmdVolumeSet IPCCmdVolumeGet )
Playback methods
const ( IPCCmdInfo = ipcCmdFirst + iota IPCCmdPathImport IPCCmdRehash IPCCmdGetID IPCCmdRemoveID IPCCmdPropertySetStr IPCCmdPropertySetInt IPCCmdPropertyRemove IPCCmdMoveURL IPCCmdMlibAddURL )
Medialib methods
const ( IPCCmdCollectionGet = ipcCmdFirst + iota IPCCmdCollectionList IPCCmdCollectionSave IPCCmdCollectionRemove IPCCmdCollectionFind IPCCmdCollectionRename IPCCmdQuery IPCCmdQueryInfos IPCCmdIDListFromPLS )
Collection methods
const ( IPCCmdGetData = ipcCmdFirst + iota IPCCmdAddData IPCCmdRemoveData IPCCmdListData )
bindata methods
const ( IPCCmdVisualizationQueryVersion = ipcCmdFirst + iota IPCCmdVisualizationRegister IPCCmdVisualizationInitSHM IPCCmdVisualizationInitUDP IPCCmdVisualizationProperty IPCCmdVisualizationProperties IPCCmdVisualizationShutdown )
visualization methods
const ( IPCCmdSendMessage = ipcCmdFirst + iota IPCCmdReplyMessage IPCCmdGetConnectedClients )
courier methods
const ( PlaylistChangedAdd = iota PlaylistChangedInsert PlaylistChangedShuffle /* deprecated */ PlaylistChangedRemove PlaylistChangedClear /* deprecated */ PlaylistChangedMove PlaylistChangedSort /* deprecated */ PlaylistChangedUpdate PlaylistChangedReplace )
Playlist changed events
const ( CollectionChangedAdd = iota CollectionChangedUpdate CollectionChangedRename CollectionChangedRemove )
Collection changed events
const ( PlaylistCurrentIDForget = iota PlaylistCurrentIDKeep PlaylistCurrentIDMoveToFront )
Playlist current ID methods
const ( PlaybackStatusStop = iota PlaybackStatusPlay PlaybackStatusPause )
Playback status
const ( PlaybackSeekCur = 1 + iota PlaybackSeekSet )
Playback seek
const ( MediaInfoReaderStatusIdle = iota MediaInfoReaderStatusRunning )
Media info reader status
const ( PluginTypeAll = iota PluginTypeOutput PluginTypeXform )
Plugin type
const ( CollectionTypeReference = iota CollectionTypeUniverse CollectionTypeUnion CollectionTypeIntersection CollectionTypeComplement CollectionTypeHas CollectionTypeMatch CollectionTypeToken CollectionTypeEquals CollectionTypeNotEqual CollectionTypeSmaller CollectionTypeSmallerEQ CollectionTypeGreater CollectionTypeGreaterEQ CollectionTypeOrder CollectionTypeLimit CollectionTypeMediaset CollectionTypeIDList CollectionTypeLast = CollectionTypeIDList )
Collection type
const ( MedialibEntryStatusNew = iota MedialibEntryStatusOK MedialibEntryStatusResolving MedialibEntryStatusNotAvailable MedialibEntryStatusRehash )
Medialib entry status
const ( LogLevelUnknown = iota LogLevelFatal LogLevelFail LogLevelError LogLevelInfo LogLevelDebug LogLevelCount /* must be last */ )
Log level
const ( C2CReplyPolicyNoReply = iota C2CReplyPolicySingleReply C2CReplyPolicyMultiReply )
C2C reply policy
const ( ErrorNone = iota ErrorGeneric ErrorOOM ErrorPermission ErrorNoEntry ErrorInval ErrorNoSausage ErrorCount /* must be last */ )
Error type
const ( ResultClassDefault = iota ResultClassSignal ResultClassBroadcast )
const ( TypeNone = iota TypeError TypeInt64 TypeString TypeColl TypeBin TypeList TypeDict TypeBitBuffer TypeFloat TypeEnd )
Value type, INT32 is same to INT64
const (
IPCCmdBrowse = ipcCmdFirst + iota
)
xform methods
const (
IPCCmdCollSyncSync = ipcCmdFirst + iota
)
Coll sync methods
const TypeInt32 = TypeInt64
In 32bit system.
Variables ¶
This section is empty.
Functions ¶
func GetUserConfDir ¶
Types ¶
type BitBuffer ¶
type BitBuffer interface { ValueNone GetBits(bits int) (int64, error) GetData(length int) ([]byte, error) PutBits(bits int, data int64) error PutBitsAt(bits int, data int64, offset int) error PutData(b []byte) error Align() error Goto(pos int) error Pos() int Rewind() error End() error Len() int GetBuffer() ([]byte, error) }
Use this BitBuffer interface to avoid native value methods.
func NewBitBuffer ¶
func NewBitBuffer() BitBuffer
type BitBufferReadonly ¶
type BitBufferReadonly interface { ValueNone GetBits(bits int) (int64, error) GetData(length int) ([]byte, error) Goto(pos int) error Pos() int Rewind() error End() error Len() int GetBuffer() ([]byte, error) }
func NewBitBufferReadonly ¶
func NewBitBufferReadonly(v []byte, length int) BitBufferReadonly
type Collection ¶
type Collection interface { ValueNone SetIDList(ids []int) AddOperand(val *Value) RemoveOperand(val *Value) GetOperands() *Value SetOperands(val *Value) IDListAppend(id int) error IDListInsert(index int, id int) error IDListMove(_old int, _new int) error IDListRemove(index int) error IDListClear() error IDListGetIndexInt32(index int) (int32, error) IDListGetIndexInt64(index int) (int64, error) IDListSetIndexInt32(index int, val int32) error IDListSetIndexInt64(index int, val int64) error IDListGetSize() int IsType(_type int) bool GetType() int IDListGet() *Value IDListSet(idlist *Value) AttributeSetString(key string, val string) AttributeSetInt32(key string, val int32) AttributeSetInt64(key string, val int64) AttributeSetValue(key string, val *Value) AttributeRemove(key string) error AttributeGetString(key string) (string, error) AttributeGetInt32(key string) (int32, error) AttributeGetInt64(key string) (int64, error) AttributeGetValue(key string) (*Value, error) AttributesGet() *Value AttributesSet(val *Value) AddOrderOperator(order *Value) Collection AddOrderOperators(order *Value) Collection AddLimitOperator(start int, length int) Collection }
func NewCollection ¶
func NewCollection(_type int) Collection
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
func NewConnector ¶
func (*Connector) BroadCastQuit ¶
func (*Connector) DisconnectCallBackSet ¶
func (c *Connector) DisconnectCallBackSet( disconnectfunc DisconnectFunc, userdata interface{}, )
When use this in parallel, a lock is needed.
func (*Connector) DisconnectCallBackSetFull ¶
func (c *Connector) DisconnectCallBackSetFull( disconnectfunc DisconnectFunc, userdata interface{}, userdatafreefunc UserDataFreeFunc, )
When use this in parallel, a lock is needed.
func (*Connector) GetLastError ¶
func (*Connector) IODisconnect ¶
func (c *Connector) IODisconnect()
func (*Connector) IOInHandle ¶
func (*Connector) IONeedOutCallbackSet ¶
func (c *Connector) IONeedOutCallbackSet( ioneedoutcallback IONeedOutCallbackFunc, userdata interface{}, )
When use this in parallel, a lock is needed.
func (*Connector) IONeedOutCallbackSetFull ¶
func (c *Connector) IONeedOutCallbackSetFull( ioneedoutcallback IONeedOutCallbackFunc, userdata interface{}, userdatafreefunc UserDataFreeFunc, )
When use this in parallel, a lock is needed.
func (*Connector) IOOutHandle ¶
func (*Connector) LockSet ¶
func (c *Connector) LockSet( lock interface{}, lockfunc LockFunc, unlockfunc UnlockFunc, )
Actually, Use native sync.Mutex is better
type Dict ¶
type Dict interface { ValueNone Get(key string) (*Value, error) Set(key string, val *Value) error Remove(key string) error Clear() error GetSize() int HasKey(key string) bool GetString(key string) (string, error) GetInt32(key string) (int32, error) GetInt64(key string) (int64, error) GetFloat32(key string) (float32, error) GetFloat64(key string) (float64, error) SetString(key string, val string) error SetInt64(key string, val int64) error SetInt32(key string, val int32) error SetFloat64(key string, val float64) error SetFloat32(key string, val float32) error GetType(key string) int FromMap(val map[string]interface{}) error ToMap() (map[string]interface{}, error) }
type DictIter ¶
type DictIter struct {
// contains filtered or unexported fields
}
func NewDictIter ¶
func (*DictIter) SetFloat32 ¶
func (*DictIter) SetFloat64 ¶
type DisconnectFunc ¶
type DisconnectFunc func(interface{})
DisconnectFunc means origin
typedef void (*xmmsc_disconnect_func_t) (void *user_data);
To convert interface{} to a struct, use:
foo := (*Foo)(v.(unsafe.Pointer))
type IONeedOutCallbackFunc ¶
type IONeedOutCallbackFunc func(int, interface{})
IONeedOutCallbackFunc means origin
typedef void (*xmmsc_io_need_out_call_back_func_t) (int, void*);
To convert interface{} to a struct, use:
foo := (*Foo)(v.(unsafe.Pointer))
type List ¶
type List interface { ValueNone Append(val *Value) error AppendFloat32(val float32) error AppendFloat64(val float64) error AppendInt32(val int32) error AppendInt64(val int64) error AppendString(val string) error Clear() error Flatten(dep int) List FromSlice(s []interface{}) error Get(pos int) (*Value, error) GetFloat32(pos int) (float32, error) GetFloat64(pos int) (float64, error) GetInt32(pos int) (int32, error) GetInt64(pos int) (int64, error) GetSize() int GetString(pos int) (string, error) GetType() (int, error) HasType(_type int) bool IndexOf(val *Value) int Insert(pos int, val *Value) error InsertFloat32(pos int, val float32) error InsertFloat64(pos int, val float64) error InsertInt32(pos int, val int32) error InsertInt64(pos int, val int64) error InsertString(pos int, val string) error Move(posOld int, posNew int) error Remove(pos int) error RestrictType(_type int) error Set(pos int, val *Value) error SetFloat32(pos int, val float32) error SetFloat64(pos int, val float64) error SetInt32(pos int, val int32) error SetInt64(pos int, val int64) error SetString(pos int, val string) error Sort(f ListCompareFunc) error ToSlice() ([]interface{}, error) }
Use this List interface to avoid native Value methods.
type ListCompareFunc ¶
ListCompareFunc means origin
typedef int (*xmmsv_list_compare_func_t)(xmmsv_t **, xmmsv_t **);
type ListIter ¶
type ListIter struct {
// contains filtered or unexported fields
}
ListIter is cursor to List
func (*ListIter) EntryFloat32 ¶
func (*ListIter) EntryFloat64 ¶
func (*ListIter) EntryInt32 ¶
func (*ListIter) EntryInt64 ¶
func (*ListIter) EntryString ¶
func (*ListIter) InsertFloat32 ¶
func (*ListIter) InsertFloat64 ¶
func (*ListIter) InsertInt32 ¶
func (*ListIter) InsertInt64 ¶
func (*ListIter) InsertString ¶
type LockFunc ¶
type LockFunc func(interface{})
LockFunc means origin
void (*lockfunc)(void *)
at xmms_client.h: 50
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
func (*Result) Disconnect ¶
func (r *Result) Disconnect()
type UnlockFunc ¶
type UnlockFunc func(interface{})
UnlockFunc means origin
void (*unlockfunc)(void *)
at xmms_client.h: 50
type UserDataFreeFunc ¶
type UserDataFreeFunc func(interface{})
UserDataFreeFunc means origin
typedef void (*xmmsc_user_data_free_func_t) (void *user_data);
To convert interface{} to a struct, use:
foo := (*Foo)(v.(unsafe.Pointer))
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
*C.xmmsv_t
func NewValueFromCopyValue ¶
func NewValueFromRef ¶
func (*Value) GetBitBuffer ¶
func (*Value) GetCollection ¶
func (x *Value) GetCollection() (Collection, error)
func (*Value) GetFloat32 ¶
func (*Value) GetFloat64 ¶
type ValueAny ¶
func NewValueFromAny ¶
func NewValueFromAny(any interface{}) ValueAny
Since Go 1.6, some Go pointer based type (like map[int]) may cause cgo panic. So return ValueNone.
type ValueBytes ¶
func NewValueFromBytes ¶
func NewValueFromBytes(b []byte) ValueBytes
type ValueError ¶
func NewValueFromError ¶
func NewValueFromError(e error) ValueError
type ValueFloat32 ¶
func NewValueFromFloat32 ¶
func NewValueFromFloat32(f float32) ValueFloat32
type ValueFloat64 ¶
func NewValueFromFloat64 ¶
func NewValueFromFloat64(f float64) ValueFloat64
type ValueInt32 ¶
func NewValueFromInt32 ¶
func NewValueFromInt32(i int32) ValueInt32
type ValueInt64 ¶
func NewValueFromInt64 ¶
func NewValueFromInt64(i int64) ValueInt64
type ValueNone ¶
type ValueNone interface { Unref() ToValue() *Value // contains filtered or unexported methods }
func NewValueFromNone ¶
func NewValueFromNone() ValueNone
type ValueString ¶
func NewValueFromString ¶
func NewValueFromString(s string) ValueString
type Xmms2Client ¶
type Xmms2Client struct {
// contains filtered or unexported fields
}
A class of xmmsclient
func NewXmms2Client ¶
func NewXmms2Client(clientName string) (*Xmms2Client, error)
Make new xmmsclient instance.
func (*Xmms2Client) Connect ¶
func (x *Xmms2Client) Connect(url string) error
Connect to xmms server, both tcp or unix socket are works.
x = NewXmms2Client("test") x.Connect("unix://somewhere") x.Connect("tcp://somewhere")
func (*Xmms2Client) CurrentID ¶
func (x *Xmms2Client) CurrentID() (int, error)
Get Current ID. If failed, return -1 and error info
func (*Xmms2Client) MediaLibInfo ¶
func (x *Xmms2Client) MediaLibInfo(id int) (map[string]interface{}, error)
Get medialib info
func (*Xmms2Client) ResultUnref ¶
func (x *Xmms2Client) ResultUnref()
Every operation is done, clear memeory is needed.
func (*Xmms2Client) Unref ¶
func (x *Xmms2Client) Unref()
You SHOULD use this when you quit.
x := NewXmms2Client("test") x.Connect("somewhere") defer x.Unref() defer x.ResultUnref() os.Exit(0)