library

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2018 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InterpolateMissingFields

func InterpolateMissingFields(track *Track)

InterpolateMissingFields extracts the artist and title from other track information if they are unavailable and applies them to the specified track.

Players should use this to homogenize their library.

Types

type DummyLibrary

type DummyLibrary []Track

DummyLibrary is used for testing.

func (*DummyLibrary) Events

func (lib *DummyLibrary) Events() *util.Emitter

Events implements the player.Player interface.

DummyLibrary is stateless, so a dummy Emitter is returned.

func (*DummyLibrary) TrackArt

func (lib *DummyLibrary) TrackArt(uri string) (image io.ReadCloser, mime string)

TrackArt implements the library.Library interface.

func (*DummyLibrary) TrackInfo

func (lib *DummyLibrary) TrackInfo(uris ...string) ([]Track, error)

TrackInfo implements the library.Library interface.

func (*DummyLibrary) Tracks

func (lib *DummyLibrary) Tracks() ([]Track, error)

Tracks implements the library.Library interface.

type Library

type Library interface {
	// An UpdateEvent may be emitted after the track library was changed.
	util.Eventer

	// Returns all available tracks in the library.
	Tracks() ([]Track, error)

	// Gets information about the specified tracks. If a track is not found, a
	// zero track is returned at that index.
	TrackInfo(uris ...string) ([]Track, error)

	// Returns the artwork for the track as a reader of image data along with
	// its MIME type. The caller is responsible for closing the reader.
	TrackArt(uri string) (image io.ReadCloser, mime string)
}

A Library is a database that is able to recall tracks that can be played.

type Track

type Track struct {
	URI         string        `json:"uri"`
	Artist      string        `json:"artist,omitempty"`
	Title       string        `json:"title,omitempty"`
	Genre       string        `json:"genre,omitempty"`
	Album       string        `json:"album,omitempty"`
	AlbumArtist string        `json:"albumartist,omitempty"`
	AlbumTrack  string        `json:"albumtrack,omitempty"`
	AlbumDisc   string        `json:"albumdisc,omitempty"`
	Duration    time.Duration `json:"duration"`
	HasArt      bool          `json:"hasart"`
}

Track holds all information associated with a single piece of music.

func AllTrackInfo

func AllTrackInfo(libs []Library, uris ...string) ([]Track, error)

AllTrackInfo looks for the track information in all the libraries supplied.

If the track is found in more than one library, precedence is given to the library at the lowest index.

func (*Track) Attr

func (track *Track) Attr(attr string) interface{}

Attr gets an attribute of a track by its name. Accepted names are:

"uri"
"artist"
"title"
"genre"
"album"
"albumartist"
"albumtrack"
"albumdisc"
"duration"

func (Track) String

func (track Track) String() string

type UpdateEvent

type UpdateEvent struct{}

An UpdateEvent is emitted when the track collection in the library has changed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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