platform

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: AGPL-3.0 Imports: 6 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

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = errors.New("platform: unsupported operation")

ErrUnsupported is returned when a provider cannot represent a requested operation. It lets the UI hide an unsupported capability instead of guessing from a platform ID.

Functions

This section is empty.

Types

type AlbumLiker

type AlbumLiker interface {
	SetAlbumLiked(context.Context, string, bool) error
}

AlbumLiker is an optional capability for platforms with starred/collected albums.

type Connector

type Connector interface {
	Provider
	Connect(context.Context) error
	Close() error
	Connected() bool
}

Connector is implemented by providers that have a sign-in or connection lifecycle, such as a local music server.

type HTTPHeaders

type HTTPHeaders interface {
	StreamHeaders(*pluginapi.Track) http.Header
}

HTTPHeaders is an optional capability for a stream that needs signed request headers. It is kept separate from Provider so ordinary providers remain simple.

type Liker

type Liker interface {
	SetLiked(context.Context, *pluginapi.Track, bool) error
}

Liker is an optional capability for platforms with a liked-song list.

type ListKind

type ListKind string

ListKind describes a list a provider can page through. The values are deliberately service-neutral; a provider maps them to its own endpoints.

const (
	ListLibrary   ListKind = "library"
	ListFavorites ListKind = "favorites"
	ListRecent    ListKind = "recent"
	ListPlaylist  ListKind = "playlist"
	ListAlbum     ListKind = "album"
	ListArtist    ListKind = "artist"
	ListAlbums    ListKind = "albums"
	ListArtists   ListKind = "artists"
)

type Lyrics

type Lyrics struct {
	LRC         string
	Translation string
	YRC         string
}

Lyrics is the common lyric payload. Translation and word-timed lyrics are optional because not every service supplies them.

type Page

type Page struct {
	Tracks    []pluginapi.Track
	Playlists []pluginapi.Playlist
	Total     int
}

Page is the common result for song and card lists. A provider fills only the fields relevant to the requested kind and always reports Total when the service provides it.

type PageRequest

type PageRequest struct {
	Kind  ListKind
	Ref   string
	Query string
	Sort  string
	Page  int
	Size  int
}

PageRequest selects one page of a provider list. Page is zero based at the seam; adapters convert it when their service uses one based pages.

type PlaylistEditor

type PlaylistEditor interface {
	CreatePlaylist(context.Context, string) (pluginapi.Playlist, error)
	RenamePlaylist(context.Context, pluginapi.Playlist, string) error
	DeletePlaylist(context.Context, pluginapi.Playlist) error
	AddToPlaylist(context.Context, pluginapi.Playlist, []pluginapi.Track) error
	RemoveFromPlaylist(context.Context, pluginapi.Playlist, []pluginapi.Track) error
}

PlaylistEditor is an optional capability for platforms whose playlists can be changed by the user.

type Provider

Provider describes the common operations of a music service client. Connection, playlist editing, likes and transcoding are optional capabilities below, so a caller does not need to type-switch on a platform name to discover what it supports.

type Registry

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

Registry stores the providers known to an app. It owns no provider lifecycle; the app switches and closes sessions explicitly.

func NewRegistry

func NewRegistry(providers ...Provider) (*Registry, error)

NewRegistry builds a registry and rejects duplicate or nil providers.

func (*Registry) Get

func (r *Registry) Get(id pluginapi.ID) Provider

Get returns the provider for id, or nil when it is not registered.

func (*Registry) IDs

func (r *Registry) IDs() []pluginapi.ID

IDs returns the registered IDs in registration order.

func (*Registry) Register

func (r *Registry) Register(p Provider) error

Register adds p to the registry. Registering an ID twice is an error so a build cannot silently replace the default platform.

type SearchKind

type SearchKind ListKind

SearchKind selects the result type returned by Search.

const (
	SearchSongs   SearchKind = "songs"
	SearchAlbums  SearchKind = "albums"
	SearchArtists SearchKind = "artists"
)

type Transcoder

type Transcoder interface {
	ShouldTranscode(*pluginapi.Track) bool
	TranscodedStream(context.Context, *pluginapi.Track, int) (*pluginapi.Stream, error)
}

Transcoder is an optional capability. The returned stream uses the shared player stream model; the concrete HLS/session implementation stays inside the provider adapter.

Jump to

Keyboard shortcuts

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