player

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoPlayerVolume when failed to get player volume
	ErrNoPlayerVolume = errors.New("failed to get player volume")
	// ErrNoArtists when failed to get artists
	ErrNoArtists = errors.New("failed to get artists")
	// ErrNoTitle when failed to get title
	ErrNoTitle = errors.New("failed to get title")
	// ErrNoID when failed to get id
	ErrNoID = errors.New("failed to get track id")
	// ErrNoLength when mpris track length is 0
	ErrNoLength = errors.New("track length is empty")
)

Functions

func Select

func Select(conn *dbus.Conn) (*mpris.Player, error)

Select selects correct parses for player

Types

type Metadata added in v0.14.0

type Metadata struct {
	Player    string `json:"player"`
	ID        string `json:"id"`
	Artist    string `json:"artist"`
	Title     string `json:"title"`
	RawArtist string `json:"raw_artist"`
	RawTitle  string `json:"raw_title"`
	Album     string `json:"album"`
	Cover     string `json:"cover"`
	URL       *URL   `json:"url"`

	Metadata map[string]dbus.Variant `json:"-"`

	Volume   float64       `json:"volume"`
	Position time.Duration `json:"position"`
	Length   time.Duration `json:"length"`
	Shuffle  bool          `json:"shuffle"`

	Status mpris.PlaybackStatus `json:"status"`
}

Metadata holds all information of currently playing track metadata

func Parse added in v0.15.0

func Parse(player *mpris.Player) (*Metadata, error)

Parse takes *mpris.Player of supported play and return *Metadata

func (*Metadata) Percentage added in v0.14.0

func (p *Metadata) Percentage() int

Percentage is player position in percentage rounded to int

func (*Metadata) UpdatePosition added in v0.14.0

func (p *Metadata) UpdatePosition(player *mpris.Player) error

UpdatePosition updates the position of player

type URL added in v0.14.0

type URL struct {
	*url.URL
}

URL wraps net.URL to provide JSON marshaling/unmarshaling

func NewURL added in v0.14.0

func NewURL(rawURL string) (*URL, error)

NewURL creates a new URL from a string

func (*URL) IsNil added in v0.14.0

func (u *URL) IsNil() bool

IsNil checks if the underlying URL is nil

func (URL) MarshalJSON added in v0.14.0

func (u URL) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (URL) String added in v0.14.0

func (u URL) String() string

String returns the string representation of the URL Implements the fmt.Stringer interface

func (*URL) UnmarshalJSON added in v0.14.0

func (u *URL) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

Jump to

Keyboard shortcuts

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