mpris2client

package module
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: MIT Imports: 6 Imported by: 0

README

mpris2client

A rough MPRIS2 controller client for internal use in go-scrobble and waybar-mpris.

go get github.com/Sonic803/mpris2client

license

MIT, see LICENSE.

Documentation

Index

Constants

View Source
const (
	INTERFACE = "org.mpris.MediaPlayer2"
	PATH      = "/org/mpris/MediaPlayer2"
	// For the NameOwnerChanged signal.
	MATCH_NOC = "type='signal',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged'"
	// For the PropertiesChanged signal. It doesn't match exactly (couldn't get that to work) so we check it manually.
	MATCH_PC = "type='signal',path='/org/mpris/MediaPlayer2',interface='org.freedesktop.DBus.Properties'"
	Refresh  = "refresh"
)

Various paths and values to use elsewhere.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Name, Value string
}

type Mpris2

type Mpris2 struct {
	List    PlayerArray
	Current uint

	Messages chan Message
	// contains filtered or unexported fields
}

func NewMpris2

func NewMpris2(conn *dbus.Conn, interpolate bool, poll int, autofocus bool) *Mpris2

func (*Mpris2) Listen

func (pl *Mpris2) Listen()

Listen should be run as a Goroutine. When players become available or are removed, an mpris2.Message is sent on mpris2.Mpris2.Messages with Name "add"/"remove" and Value as the player name. When a players state changes, a message is sent on mpris2.Mpris2.Messages with Name "refresh".

func (*Mpris2) New

func (pl *Mpris2) New(name string)

func (*Mpris2) Refresh

func (pl *Mpris2) Refresh()

func (*Mpris2) Reload

func (pl *Mpris2) Reload() error

func (*Mpris2) Remove

func (pl *Mpris2) Remove(fullName string)

func (*Mpris2) Sort

func (pl *Mpris2) Sort()

func (*Mpris2) String

func (pl *Mpris2) String() string

type Player

type Player struct {
	Player                                            dbus.BusObject
	FullName, Name, Title, Artist, AlbumArtist, Album string
	TrackNumber, Length                               int // -1 when track number unavailable
	Position                                          int64

	Playing, Stopped bool
	// contains filtered or unexported fields
}

Player represents an active media player.

func NewPlayer

func NewPlayer(conn *dbus.Conn, name string, interpolate bool, poll int) (p *Player)

NewPlayer returns a new player object.

func (*Player) Exists

func (p *Player) Exists() bool

func (*Player) GetPosition

func (p *Player) GetPosition() bool

func (*Player) Next

func (p *Player) Next()

Next requests the next track.

func (*Player) Previous

func (p *Player) Previous()

Previous requests the previous track.

func (*Player) Refresh

func (p *Player) Refresh() int

Refresh grabs playback info.

func (*Player) String

func (p *Player) String() string

func (*Player) StringPosition

func (p *Player) StringPosition() string

StringPosition figures out the track position in MM:SS/MM:SS, interpolating the value if necessary.

func (*Player) Toggle

func (p *Player) Toggle()

Toggle requests play/pause

type PlayerArray

type PlayerArray []*Player

func (PlayerArray) Len

func (ls PlayerArray) Len() int

func (PlayerArray) Less

func (ls PlayerArray) Less(i, j int) bool

func (PlayerArray) Swap

func (ls PlayerArray) Swap(i, j int)

Jump to

Keyboard shortcuts

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