libnp

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: MIT Imports: 5 Imported by: 3

README

go-libnp GoDoc

A tiny cross-platform library for extracting information about the music/image/video that is Now Playing on the system. No CGo required!

Supported OS:

  • Windows (using GlobalSystemMediaTransportControlsSessionManager)
  • Linux (using plain Go: DBus/MPRIS)

This is essentially libnp rewritten in plain Go.

Usage

The API is well-documented in its GoDoc

info, err := libnp.GetInfo(context.Background())
fmt.Println(info.Album)

Status

Used in small-scale production environments.

The API could be slightly changed in backwards-incompatible ways for now.

  • Add darwin
  • Add web

License

MIT

Documentation

Overview

Package libnp offers information about the media that is currently being played. The main entrypoint is GetInfo, which returns an Info.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	AlbumArtists    []string
	Artists         []string
	Composers       []string  // linux only
	Genres          []string  // linux only
	Lyricists       []string  // linux only
	Created         time.Time // linux only
	FirstPlayed     time.Time // linux only
	LastPlayed      time.Time // linux only
	Album           string
	AlbumTrackCount int           // windows only
	ArtURL          string        // linux only
	BPM             int           // linux only
	DiscNumber      int           // linux only
	Length          time.Duration // linux only
	PlayCount       int           // linux only
	Subtitle        string        // windows only
	Title           string
	TrackNumber     int
	URL             string       // linux only
	PlaybackType    PlaybackType // windows only
}

Info stores information about the media being played.

func GetInfo

func GetInfo(ctx context.Context) (*Info, error)

GetInfo returns Info about the media currently being played.

An error is returned if the library has issues getting valid information about the song being played.

A nil Info with a nil error is returned if there is no media being played.

type PlaybackType

type PlaybackType int

PlaybackType represents the kind of media being played. PlaybackTypeUnknown is used on some platforms.

const (
	PlaybackTypeUnknown PlaybackType = iota
	PlaybackTypeMusic
	PlaybackTypeVideo
	PlaybackTypeImage
)

func (PlaybackType) String

func (p PlaybackType) String() string

Directories

Path Synopsis
cmd
np command

Jump to

Keyboard shortcuts

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