mpris

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

README

MPRIS Library

This library contains both a client and server for the MPRIS protocol, which the musicwand library uses.

The client code works similarly to how many clients work. You get a handle, then are able to search for the player you want and send it commands using methods.

client, err := mpris.NewClient()
if err != nil {
	fmt.Fprintf(os.Stderr, err.Error())
	os.Exit(1)
}

app = client.FindApp("vlc")
if app.Identity() == "" {
	fmt.Fprintf(os.Stderr, "Couldn't find the vlc player interface")
	os.Exit(1)
}
player = app.Player()

player.Play()
player.Next()

The server is more complex. You must instantiate a new server, then supply it with subservers which can answer the necessary functions of the MPRIS API. You can optionally attach extra interfaces onto the same object to augment the behavior.

	server, err := mpris.NewServer("musicwand")
	if err != nil {
		log.Fatal(err)
	}

	server.PropertyHandler = &propertyHandler{}
	server.AppServer = &appServer{}
	server.PlayerServer = &playerServer{}

  server.AddInterface("com.github.username.service", &customServer{})

	if err := server.Listen(); err != nil {
		log.Fatal(err)
	}

Examples of this can be seen in the musicwand application source code.

Documentation

Index

Constants

View Source
const (
	PlaybackPlaying     PlaybackState = "Playing"
	PlaybackPaused                    = "Paused"
	PlaybackStopped                   = "Stopped"
	PlaybackUnsupported               = ""

	LoopNone     LoopState = "None"
	LoopTrack              = "Track"
	LoopPlaylist           = "Playlist"
)

Variables

This section is empty.

Functions

func DbusError

func DbusError(err error) *dbus.Error

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient() (*Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) FindPlayer

func (c *Client) FindPlayer(name string) *Player

func (*Client) OnAnyPlayerChange

func (c *Client) OnAnyPlayerChange() (chan *dbus.Signal, error)

func (*Client) PlayerWithOwner

func (c *Client) PlayerWithOwner(owner string) *Player

func (*Client) Players

func (c *Client) Players() (players []Player)

type HandlesProperties

type HandlesProperties interface {
	Get(iface, prop string) (dbus.Variant, *dbus.Error)
	GetAll(iface string) (map[string]dbus.Variant, *dbus.Error)
	Set(iface, prop string, value dbus.Variant) *dbus.Error
}

type IsApp

type IsApp interface {
	Quit() *dbus.Error
	Raise() *dbus.Error
}

type IsPlayer

type IsPlayer interface {
	Next() *dbus.Error
	OpenUri(uri string) *dbus.Error
	Pause() *dbus.Error
	Play() *dbus.Error
	PlayPause() *dbus.Error
	Previous() *dbus.Error
	Seek(delta int64) *dbus.Error
	SetPosition(trackId string, position int64) *dbus.Error
	Stop() *dbus.Error
}

type LoopState

type LoopState string

type PlaybackState

type PlaybackState string

type Player

type Player struct {
	Name  string
	Owner string
	// contains filtered or unexported fields
}

func (*Player) CanControl

func (p *Player) CanControl() bool

func (*Player) CanGoNext

func (p *Player) CanGoNext() bool

func (*Player) CanGoPrevious

func (p *Player) CanGoPrevious() bool

func (*Player) CanPause

func (p *Player) CanPause() bool

func (*Player) CanPlay

func (p *Player) CanPlay() bool

func (*Player) CanQuit

func (p *Player) CanQuit() bool

func (*Player) CanRaise

func (p *Player) CanRaise() bool

func (*Player) CanSeek

func (p *Player) CanSeek() bool

func (*Player) CanSetFullscreen

func (p *Player) CanSetFullscreen() bool

func (*Player) DesktopEntry

func (p *Player) DesktopEntry() string

func (*Player) Fullscreen

func (p *Player) Fullscreen(value ...bool) bool

func (*Player) Get

func (p *Player) Get(iface, prop string) (result dbus.Variant, err error)

func (*Player) GetAll

func (p *Player) GetAll(iface string) (result map[string]dbus.Variant, err error)

func (*Player) HasTrackList

func (p *Player) HasTrackList() bool

func (*Player) Identity

func (p *Player) Identity() string

Properties on app: org.mpris.MediaPlayer2

func (*Player) Introspect

func (p *Player) Introspect() (*introspect.Node, error)

func (*Player) LoopStatus

func (p *Player) LoopStatus() LoopState

func (*Player) MaximumRate

func (p *Player) MaximumRate() float64

func (*Player) MinimumRate

func (p *Player) MinimumRate() float64

func (*Player) Next

func (p *Player) Next() error

func (*Player) OnChange

func (p *Player) OnChange() (chan *dbus.Signal, error)

func (*Player) OnSeek

func (p *Player) OnSeek() (chan *dbus.Signal, error)

Signals

func (*Player) OpenUri

func (p *Player) OpenUri(uri string) error

func (*Player) Pause

func (p *Player) Pause() error

func (*Player) Play

func (p *Player) Play() error

Methods on playback: org.mpris.MediaPlayer2.Player

func (*Player) PlayPause

func (p *Player) PlayPause() error

func (*Player) PlaybackStatus

func (p *Player) PlaybackStatus() PlaybackState

func (*Player) Position

func (p *Player) Position() int64

func (*Player) Previous

func (p *Player) Previous() error

func (*Player) Quit

func (p *Player) Quit() error

func (*Player) Raise

func (p *Player) Raise() error

Methods on app: org.mpris.MediaPlayer2

func (*Player) Rate

func (p *Player) Rate(value ...float64) float64

func (*Player) RawMetadata

func (p *Player) RawMetadata() map[string]dbus.Variant

func (*Player) Seek

func (p *Player) Seek(delta int64) error

func (*Player) Set

func (p *Player) Set(iface, prop string, value interface{}) (err error)

func (*Player) SetPosition

func (p *Player) SetPosition(trackId string, position int64) error

func (*Player) Shuffle

func (p *Player) Shuffle(value ...bool) bool

Properties on playback: org.mpris.MediaPlayer2.Player

func (*Player) Stop

func (p *Player) Stop() error

func (*Player) SupportedMimeTypes

func (p *Player) SupportedMimeTypes() []string

func (*Player) SupportedUriSchemes

func (p *Player) SupportedUriSchemes() []string

func (*Player) Volume

func (p *Player) Volume(value ...float64) float64

type Server

type Server struct {
	Conn            *dbus.Conn
	Name            string
	AppServer       IsApp
	PlayerServer    IsPlayer
	PropertyHandler HandlesProperties
	// contains filtered or unexported fields
}

MPRIS Server

Create and listen to start application.

func NewServer

func NewServer(name string) (*Server, error)

func (*Server) AddInterface

func (s *Server) AddInterface(name string, handler interface{})

func (*Server) Close

func (s *Server) Close()

func (*Server) Listen

func (s *Server) Listen() error

Jump to

Keyboard shortcuts

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