barista.run: barista.run/modules/media Index | Files

package media

import "barista.run/modules/media"

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

Index

Package Files

info.go media.go

Constants

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")
)

type AutoModule Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

func (i Info) Connected() bool

Connected returns true if the media player is connected.

func (Info) Next Uses

func (i Info) Next()

Next switches to the next track.

func (Info) Pause Uses

func (i Info) Pause()

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

func (Info) Paused Uses

func (i Info) Paused() bool

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

func (Info) Play Uses

func (i Info) Play()

Play starts playback of the current track.

func (Info) PlayPause Uses

func (i Info) PlayPause()

PlayPause toggles between playing and paused.

func (Info) Playing Uses

func (i Info) Playing() bool

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

func (Info) Position Uses

func (i Info) Position() time.Duration

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

func (Info) Previous Uses

func (i Info) Previous()

Previous switches to the previous track.

func (Info) Seek Uses

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

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

func (Info) Stop Uses

func (i Info) Stop()

Stop stops playback and resets the playback position.

func (Info) Stopped Uses

func (i Info) Stopped() bool

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

func (Info) TruncatedPosition Uses

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 Uses

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 Uses

func New(player string) *Module

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

func (*Module) Output Uses

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 Uses

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 Uses

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 Uses

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

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

type PlaybackStatus Uses

type PlaybackStatus string

PlaybackStatus represents the state of the media player.

Package media imports 12 packages (graph) and is imported by 2 packages. Updated 2019-11-19. Refresh now. Tools for package owners.