media

package
v0.0.0-...-c936f35 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 12 Imported by: 21

Documentation

Overview

Package media provides an i3bar module for an MPRIS-compatible media player.

Index

Constants

View Source
const (
	// Disconnected when the player is not running.
	Disconnected = PlaybackStatus("")
	// Playing when the player is actively playing a track.
	Playing = PlaybackStatus("Playing")
	// Paused when some media is selected but paused.
	Paused = PlaybackStatus("Paused")
	// Stopped when no media is selected or playing.
	Stopped = PlaybackStatus("Stopped")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoModule

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

AutoModule is a media module that automatically switches to the newest media player seen on D-Bus.

func Auto

func Auto(excluding ...string) *AutoModule

Auto constructs an instance of the media module that shows the most recently connected player (based on D-Bus name acquisition). It can optionally ignore one or more named players from this detection.

func (*AutoModule) Output

func (m *AutoModule) Output(outputFunc func(Info) bar.Output) *AutoModule

Output configures a module to display the output of a user-defined function.

func (*AutoModule) RepeatingOutput

func (m *AutoModule) RepeatingOutput(outputFunc func(Info) bar.Output) *AutoModule

RepeatingOutput configures a module to display the output of a user-defined function, automatically repeating it every second while playing.

func (*AutoModule) Stream

func (m *AutoModule) Stream(s bar.Sink)

Stream starts the module and the D-Bus listener for media player name acquisitions and releases.

type Info

type Info struct {
	PlayerName     string
	PlaybackStatus PlaybackStatus
	Shuffle        bool
	// From Metadata
	Length      time.Duration
	Title       string
	Artist      string
	Album       string
	AlbumArtist string
	// Although ArtURL cannot be used in the module output, it can still be
	// used for notifications or colour extraction.
	ArtURL string
	// contains filtered or unexported fields
}

Info represents the current information from the media player.

func (Info) Connected

func (i Info) Connected() bool

Connected returns true if the media player is connected.

func (Info) Next

func (i Info) Next()

Next switches to the next track.

func (Info) Pause

func (i Info) Pause()

Pause pauses the current track, keeping the current playback position.

func (Info) Paused

func (i Info) Paused() bool

Paused returns true if the media player is connected and paused.

func (Info) Play

func (i Info) Play()

Play starts playback of the current track.

func (Info) PlayPause

func (i Info) PlayPause()

PlayPause toggles between playing and paused.

func (Info) Playing

func (i Info) Playing() bool

Playing returns true if the media player is connected and playing media.

func (Info) Position

func (i Info) Position() time.Duration

Position computes the current track position based on the last update from the media player.

func (Info) Previous

func (i Info) Previous()

Previous switches to the previous track.

func (Info) Seek

func (i Info) Seek(offset time.Duration)

Seek seeks to the given position within the currently playing track.

func (Info) Stop

func (i Info) Stop()

Stop stops playback and resets the playback position.

func (Info) Stopped

func (i Info) Stopped() bool

Stopped returns true if the media player is connected but stopped.

func (Info) TruncatedPosition

func (i Info) TruncatedPosition(unit string) string

TruncatedPosition truncates the current position to the given unit, to avoid unnecessary decimals (e.g. 1m3.0032s becomes 1m3s for "s")

type Module

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

Module represents a bar.Module that displays media information from an MPRIS-compatible media player.

func New

func New(player string) *Module

New constructs an instance of the media module for the given player.

func (*Module) Output

func (m *Module) Output(outputFunc func(Info) bar.Output) *Module

Output configures a module to display the output of a user-defined function.

func (*Module) Player

func (m *Module) Player(player string) *Module

Player sets the name of the player to track. This will disconnect the module from the previous player.

func (*Module) RepeatingOutput

func (m *Module) RepeatingOutput(outputFunc func(Info) bar.Output) *Module

RepeatingOutput configures a module to display the output of a user-defined function, automatically repeating it every second while playing.

func (*Module) Stream

func (m *Module) Stream(s bar.Sink)

Stream sets up d-bus connections and starts the module.

type PlaybackStatus

type PlaybackStatus string

PlaybackStatus represents the state of the media player.

Jump to

Keyboard shortcuts

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