nowplaying

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package nowplaying provides Experimental system media metadata and media keys.

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("nowplaying: session closed")

ErrClosed is returned when updating a closed session.

Functions

This section is empty.

Types

type Options

type Options struct {
	ID                                  string // application identifier, e.g. "com.example.player"
	Name                                string
	Play, Pause, Toggle, Next, Previous func()
	Seek                                func(time.Duration)
	// contains filtered or unexported fields
}

Options identifies the application and supplies its supported controls. Leave unsupported callbacks nil. Callbacks run on the app's main thread.

type Playback

type Playback uint8

Playback describes whether the current item is playing.

const (
	Stopped Playback = iota
	Paused
	Playing
)

type Session

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

Session owns a system media session. Create it in OnReady or once the app is running. The session is closed when the app terminates.

func New

func New(app *tango.App, opts Options) (*Session, error)

New registers a system media session. A backend without media integration returns tango.ErrUnsupported.

func (*Session) Close

func (s *Session) Close() error

Close unregisters the media session. It is safe to call repeatedly.

func (*Session) Update

func (s *Session) Update(state State) error

Update publishes a new snapshot to the system.

type State

type State struct {
	Title, Artist, Album, TrackID string
	Duration, Position            time.Duration
	Rate                          float64
	Playback                      Playback
	// contains filtered or unexported fields
}

State is a playback snapshot. Position and Duration use media time. Rate defaults to 1. TrackID identifies the item across metadata updates.

Jump to

Keyboard shortcuts

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