backend

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2025 License: GPL-3.0 Imports: 62 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoServers       = errors.New("no servers set up")
	ErrAnotherInstance = errors.New("another instance is running")
)
View Source
var (
	VolumeCLIArg         int     = -1
	SeekToCLIArg         float64 = -1
	SeekByCLIArg         float64 = 0
	VolumePctCLIArg      float64 = 0
	PlayAlbumCLIArg      string  = ""
	PlayPlaylistCLIArg   string  = ""
	PlayTrackCLIArg      string  = ""
	FirstTrackCLIArg     int     = 0
	SearchAlbumCLIArg    string  = ""
	SearchPlaylistCLIArg string  = ""
	SearchTrackCLIArg    string  = ""

	FlagPlay             = flag.Bool("play", false, "unpause or begin playback")
	FlagPause            = flag.Bool("pause", false, "pause playback")
	FlagPlayPause        = flag.Bool("play-pause", false, "toggle play/pause state")
	FlagPrevious         = flag.Bool("previous", false, "seek to previous track or beginning of current")
	FlagNext             = flag.Bool("next", false, "seek to next track")
	FlagStop             = flag.Bool("stop", false, "stop playback")
	FlagStopAfterCurrent = flag.Bool("stop-after-current", false, "stop playback after current track")
	FlagStartMinimized   = flag.Bool("start-minimized", false, "start app minimized")
	FlagShow             = flag.Bool("show", false, "show minimized app")
	FlagShuffle          = flag.Bool("shuffle", false, "shuffle the tracklist (to be used with either -play-album-by-id or -play-playlist-by-id)")
	FlagVersion          = flag.Bool("version", false, "print app version and exit")
	FlagHelp             = flag.Bool("help", false, "print command line options and exit")

	FlagPlayAlbum    *bool
	FlagPlayPlaylist *bool
	FlagPlayTrack    *bool
)
View Source
var (
	ReplayGainNone  = player.ReplayGainNone.String()
	ReplayGainAlbum = player.ReplayGainAlbum.String()
	ReplayGainTrack = player.ReplayGainTrack.String()
	ReplayGainAuto  = "Auto"
)
View Source
var (
	ErrNotFound = errors.New("item not found")
)
View Source
var ErrUnreachable = errors.New("server is unreachable")
View Source
var SupportedStartupPages = []string{"Albums", "Favorites", "Playlists"}

Functions

func HaveCommandLineOptions added in v0.12.0

func HaveCommandLineOptions() bool

func InitMPMediaHandler added in v0.6.0

func InitMPMediaHandler(playbackManager *PlaybackManager, artURLLookup func(trackID string) (string, error)) error

func NewCommandQueue added in v0.13.2

func NewCommandQueue() *playbackCommandQueue

func NewPlaybackEngine added in v0.9.0

func NewPlaybackEngine(
	ctx context.Context,
	s *ServerManager,
	c *AudioCache,
	p player.BasePlayer,
	playbackCfg *PlaybackConfig,
	scrobbleCfg *ScrobbleConfig,
	transcodeCfg *TranscodingConfig,
) *playbackEngine

func SavePlayQueue added in v0.9.0

func SavePlayQueue(serverID string, pm *PlaybackManager, filepath string, server mediaprovider.CanSavePlayQueue) error

SavePlayQueue saves the current play queue and playback position to a JSON file. If the provided CanSavePlayQueue server is non-nil, it will also save to the server.

func SetSystemSleepDisabled added in v0.13.0

func SetSystemSleepDisabled(disable bool)

Types

type AlbumPageConfig

type AlbumPageConfig struct {
	TracklistColumns []string
}

type AlbumsPageConfig

type AlbumsPageConfig struct {
	SortOrder   string // only relevant for Albums page
	ShowYears   bool
	ShuffleMode string // only relevant for Genre page
	PlayInOrder bool   // only relevant for Albums page
}

shared between Albums and Genre pages

type App

type App struct {
	Config          *Config
	ServerManager   *ServerManager
	ImageManager    *ImageManager
	AudioCache      *AudioCache
	PlaybackManager *PlaybackManager
	LocalPlayer     *mpv.Player
	UpdateChecker   UpdateChecker
	MPRISHandler    *MPRISHandler
	WinSMTC         *windows.SMTC

	LrcLibFetcher *LrcLibFetcher

	// UI callbacks to be set in main
	OnReactivate func()
	OnExit       func()
	// contains filtered or unexported fields
}

func AppInstance added in v0.16.0

func AppInstance() *App

func StartupApp

func StartupApp(appName, displayAppName, appVersion, appVersionTag, latestReleaseURL string) (*App, error)

func (*App) DeleteServerCacheDir

func (a *App) DeleteServerCacheDir(serverID uuid.UUID) error

func (*App) IsFirstLaunch added in v0.7.0

func (a *App) IsFirstLaunch() bool

func (*App) IsPortableMode added in v0.11.0

func (a *App) IsPortableMode() bool

func (*App) LoadSavedPlayQueue added in v0.9.0

func (a *App) LoadSavedPlayQueue() error

func (*App) LoginToDefaultServer

func (a *App) LoginToDefaultServer() error

func (*App) SaveConfigFile added in v0.8.0

func (a *App) SaveConfigFile()

func (*App) SavePlayQueueIfEnabled added in v0.13.1

func (a *App) SavePlayQueueIfEnabled()

func (*App) SetupWindowsSMTC added in v0.14.0

func (a *App) SetupWindowsSMTC(hwnd uintptr)

func (*App) SetupWindowsTaskbarButtons added in v0.18.0

func (a *App) SetupWindowsTaskbarButtons(hwnd uintptr)

func (*App) Shutdown

func (a *App) Shutdown()

func (*App) ThemesDir added in v0.11.0

func (a *App) ThemesDir() string

func (*App) VersionTag

func (a *App) VersionTag() string

type AppConfig

type AppConfig struct {
	WindowWidth                 int
	WindowHeight                int
	LastCheckedVersion          string
	LastLaunchedVersion         string
	EnableSystemTray            bool
	CloseToSystemTray           bool
	StartupPage                 string
	SettingsTab                 string
	AllowMultiInstance          bool
	MaxImageCacheSizeMB         int
	SavePlayQueue               bool
	SaveQueueToServer           bool
	DefaultPlaylistID           string
	AddToPlaylistSkipDuplicates bool
	ShowTrackChangeNotification bool
	EnableLrcLib                bool
	CustomLrcLibUrl             string
	EnablePasswordStorage       bool
	SkipSSLVerify               bool
	EnqueueBatchSize            int
	Language                    string
	DisableDPIDetection         bool
	EnableAutoUpdateChecker     bool
	RequestTimeoutSeconds       int
	EnableOSMediaPlayerAPIs     bool

	FontNormalTTF string
	FontBoldTTF   string
	UIScaleSize   string
}

type ArtistPageConfig

type ArtistPageConfig struct {
	InitialView      string
	DiscographySort  string
	TracklistColumns []string
}

type ArtistsPageConfig added in v0.10.0

type ArtistsPageConfig struct {
	SortOrder string
}

type AudioCache added in v0.18.0

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

AudioCache manages temporary local storage of audio files fetched from the remote music server. It prefetches and stores tracks on disk based on an upcoming play queue.

func NewAudioCache added in v0.18.0

func NewAudioCache(ctx context.Context, s *ServerManager, baseCacheDir string) (*AudioCache, error)

NewAudioCache initializes an AudioCache using the given context, server manager, and local filesystem directory for storing audio files.

func (*AudioCache) CacheFile added in v0.18.0

func (a *AudioCache) CacheFile(id, dlURL string)

CacheFile begins downloading a file (if not already downloading) and stores it to the cache directory under its ID as filename. The download is asynchronous.

func (*AudioCache) CacheOnly added in v0.18.0

func (a *AudioCache) CacheOnly(keep string, fetch []AudioCacheRequest)

CacheOnly ensures that only the given 'fetch' list of files (plus one extra 'keep' ID) remain cached. Any other cached files are cancelled and deleted from disk.

func (*AudioCache) IsFullyDownloaded added in v0.18.0

func (a *AudioCache) IsFullyDownloaded(id string) bool

IsFullyDownloaded returns true if the file for the given id is fully downloaded.

func (*AudioCache) ObtainReferenceToFile added in v0.18.0

func (a *AudioCache) ObtainReferenceToFile(id string) string

If it is not cached or downloading, it returns an empty string.

func (*AudioCache) PathForCachedFile added in v0.18.0

func (a *AudioCache) PathForCachedFile(id string) string

PathForCachedFile returns the local filesystem path for a cached track, if the file has finished downloading. If not cached, it returns an empty string.

func (*AudioCache) PathForCachedOrDownloadingFile added in v0.18.0

func (a *AudioCache) PathForCachedOrDownloadingFile(id string) string

PathForCachedFile returns the local filesystem path for a cached track, including one that is in the process of downloading. If it is not cached or downloading, it returns an empty string.

func (*AudioCache) ReleaseReferenceToFile added in v0.18.0

func (a *AudioCache) ReleaseReferenceToFile(id string)

func (*AudioCache) Shutdown added in v0.18.0

func (a *AudioCache) Shutdown()

Shutdown cancels all in-progress downloads and deletes all files in the audio cache directory. This should be called during application shutdown to clean up temporary audio data.

type AudioCacheRequest added in v0.18.0

type AudioCacheRequest struct {
	ID          string
	DownloadURL string
}

AudioCacheRequest represents a request to prefetch and cache an audio file.

type CacheItem

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

type Config

type Config struct {
	Application      AppConfig
	Servers          []*ServerConfig
	AlbumPage        AlbumPageConfig
	AlbumsPage       AlbumsPageConfig
	ArtistPage       ArtistPageConfig
	ArtistsPage      ArtistsPageConfig
	FavoritesPage    FavoritesPageConfig
	GridView         GridViewConfig
	PlaylistPage     PlaylistPageConfig
	PlaylistsPage    PlaylistsPageConfig
	TracksPage       TracksPageConfig
	NowPlayingConfig NowPlayingPageConfig
	Playback         PlaybackConfig
	LocalPlayback    LocalPlaybackConfig
	Scrobbling       ScrobbleConfig
	ReplayGain       ReplayGainConfig
	Transcoding      TranscodingConfig
	Theme            ThemeConfig
	PeakMeter        PeakMeterConfig
}

func DefaultConfig

func DefaultConfig(appVersionTag string) *Config

func ReadConfigFile

func ReadConfigFile(filepath, appVersionTag string) (*Config, error)

func (*Config) WriteConfigFile

func (c *Config) WriteConfigFile(filepath string) error

type FavoritesPageConfig

type FavoritesPageConfig struct {
	InitialView      string
	TracklistColumns []string
	ShowAlbumYears   bool
}

type GridViewConfig added in v0.16.0

type GridViewConfig struct {
	CardSize float32
}

type ImageCache

type ImageCache struct {
	MinSize    int
	MaxSize    int
	DefaultTTL time.Duration

	// Sets a callback that is invoked whenever the periodic
	// eviction has been run. Allows for "tacking on" extra
	// cleanup tasks outside of the ImageCache's jurisdiction
	// that are run on the same schedule.
	OnEvictTaskRan func()
	// contains filtered or unexported fields
}

A custom in-memory cache for images with the following eviction strategy:

  1. If there are fewer than MinSize items in the cache, none will be evicted
  2. If a new addition would make the cache exceed MaxSize, an item will be immediately evicted 2a. in this case, evict the LRU expired item or if none expired, the LRU item
  3. If the size of the cache is between MaxSize and MinSize, expired items will be periodically evicted 3a. in this case, again the least recently used expired items will be evicted first

func (*ImageCache) Clear added in v0.5.2

func (i *ImageCache) Clear()

func (*ImageCache) EvictExpired

func (i *ImageCache) EvictExpired()

EvictExpired evicts least recently used expired items from the cache until there are no more expired items or the cache contains MinSize elements Holds the reader lock for O(n) time and writer lock for O(n)

func (*ImageCache) Get

func (i *ImageCache) Get(key string) (image.Image, error)

func (*ImageCache) GetExtendTTL

func (i *ImageCache) GetExtendTTL(key string, ttl time.Duration) (image.Image, error)

Gets the image if it exists and extends TTL to time.Now + ttl iff the image would expire before then

func (*ImageCache) GetResetTTL

func (i *ImageCache) GetResetTTL(key string, resetTTL bool) (image.Image, error)

func (*ImageCache) GetWithNewTTL

func (i *ImageCache) GetWithNewTTL(key string, newTtl time.Duration) (image.Image, error)

func (*ImageCache) Has

func (i *ImageCache) Has(key string) bool

func (*ImageCache) Init

func (i *ImageCache) Init(ctx context.Context, evictionInterval time.Duration)

func (*ImageCache) Set

func (i *ImageCache) Set(key string, val image.Image)

func (*ImageCache) SetWithTTL

func (i *ImageCache) SetWithTTL(key string, val image.Image, ttl time.Duration)

holds writer lock for O(i.MaxSize) worst case

type ImageManager

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

The ImageManager is responsible for retrieving and serving images to the UI layer. It maintains an in-memory cache of recently used images for immediate future access, and a larger on-disc cache of images that is periodically re-requested from the server.

func NewImageManager

func NewImageManager(ctx context.Context, s *ServerManager, baseCacheDir string) *ImageManager

NewImageManager returns a new ImageManager.

func (*ImageManager) FetchAndCacheArtistImage

func (i *ImageManager) FetchAndCacheArtistImage(artistID string, imgURL string) (image.Image, error)

FetchAndCacheArtistImage fetches the artist image for the given artistID from the server, caching it locally if the fetch succeeds. Blocks until fetch is completed.

func (*ImageManager) GetCachedArtistImage

func (i *ImageManager) GetCachedArtistImage(artistID string) (image.Image, bool)

GetCachedArtistImage returns the artist image for the given artistID from the on-disc cache, if it exists.

func (*ImageManager) GetCoverArtPath added in v0.14.0

func (i *ImageManager) GetCoverArtPath(coverID string) (string, error)

GetCoverArtPath returns the file path for the locally cached cover thumbnail, if it exists.

func (*ImageManager) GetCoverArtUrl added in v0.5.0

func (i *ImageManager) GetCoverArtUrl(coverID string) (string, error)

GetCoverArtURL returns the URL for the locally cached cover thumbnail, if it exists.

func (*ImageManager) GetCoverThumbnail

func (i *ImageManager) GetCoverThumbnail(coverID string) (image.Image, error)

GetCoverThumbnail is a synchronous, blocking function to fetch the image for a given coverID. Like most ImageManager calls, it should usually be called in a goroutine to not block UI loading.

func (*ImageManager) GetCoverThumbnailAsync added in v0.5.2

func (i *ImageManager) GetCoverThumbnailAsync(coverID string, cb func(image.Image, error)) context.CancelFunc

GetCoverThumbnailAsync asynchronously fetches the cover image for the given ID, and invokes the callback on completion. It returns a context.CancelFunc which can be used to cancel the fetch. The callback will not be invoked if the fetch is cancelled before completion. The cancel func must be invoked to avoid resource leaks. Use GetCoverThumbnail if cancellation is not needed.

func (*ImageManager) GetCoverThumbnailFromCache

func (i *ImageManager) GetCoverThumbnailFromCache(coverID string) (image.Image, bool)

GetCoverThumbnailFromCache returns the cover thumbnail for the given ID if it exists in the in-memory cache. Returns quickly, safe to call in UI threads.

func (*ImageManager) GetFullSizeCoverArt

func (i *ImageManager) GetFullSizeCoverArt(coverID string) (image.Image, error)

GetFullSizeCoverArt fetches the full size cover image for the given coverID. It blocks until the fetch is complete.

func (*ImageManager) GetFullSizeCoverArtAsync added in v0.10.0

func (i *ImageManager) GetFullSizeCoverArtAsync(coverID string, cb func(image.Image, error)) context.CancelFunc

GetCoverThumbnailAsync asynchronously fetches the cover image for the given ID, and invokes the callback on completion. It returns a context.CancelFunc which can be used to cancel the fetch. The callback will not be invoked if the fetch is cancelled before completion. The cancel func must be invoked to avoid resource leaks. Use GetCoverThumbnail if cancellation is not needed.

func (*ImageManager) RefreshCachedArtistImageIfExpired

func (i *ImageManager) RefreshCachedArtistImageIfExpired(artistID string, imgURL string) error

RefreshCachedArtistImageIfExpired re-fetches the artist image from the server if expired.

func (*ImageManager) SetMaxOnDiskCacheSizeBytes added in v0.5.2

func (i *ImageManager) SetMaxOnDiskCacheSizeBytes(size int64)

SetMaxOnDiskCacheSizeBytes sets the maximum size of the on-disc cover thumbnail cache. A periodic clean task will delete least recently accessed images to maintain the size limit.

type InsertQueueMode added in v0.10.0

type InsertQueueMode int
const (
	Replace InsertQueueMode = iota
	InsertNext
	Append
)

type LocalPlaybackConfig

type LocalPlaybackConfig struct {
	AudioDeviceName       string
	AudioExclusive        bool
	InMemoryCacheSizeMB   int
	Volume                int
	EqualizerEnabled      bool
	EqualizerPreamp       float64
	GraphicEqualizerBands []float64
}

type LoopMode added in v0.5.0

type LoopMode int

The playback loop mode (LoopNone, LoopAll, LoopOne).

const (
	LoopNone LoopMode = iota
	LoopAll
	LoopOne
)

type LrcLibFetcher added in v0.14.0

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

func NewLrcLibFetcher added in v0.14.0

func NewLrcLibFetcher(baseCacheDir string, customLrcLibUrl string, timeout time.Duration) *LrcLibFetcher

func (*LrcLibFetcher) FetchLrcLibLyrics added in v0.14.0

func (l *LrcLibFetcher) FetchLrcLibLyrics(name, artist, album string, durationSecs int) (*mediaprovider.Lyrics, error)

type MPRISHandler added in v0.5.0

type MPRISHandler struct {
	// Function called if the player is requested to quit through MPRIS.
	// Should *asynchronously* start shutdown and return immediately true if a shutdown will happen.
	OnQuit func() error

	// Function called if the player is requested to bring its UI to the front.
	OnRaise func() error

	// Function to look up the artwork URL for a given track ID
	ArtURLLookup func(trackID string) (string, error)
	// contains filtered or unexported fields
}

func NewMPRISHandler added in v0.5.0

func NewMPRISHandler(playerName string, pm *PlaybackManager) *MPRISHandler

func (*MPRISHandler) CanControl added in v0.5.0

func (m *MPRISHandler) CanControl() (bool, error)

func (*MPRISHandler) CanGoNext added in v0.5.0

func (m *MPRISHandler) CanGoNext() (bool, error)

func (*MPRISHandler) CanGoPrevious added in v0.5.0

func (m *MPRISHandler) CanGoPrevious() (bool, error)

func (*MPRISHandler) CanPause added in v0.5.0

func (m *MPRISHandler) CanPause() (bool, error)

func (*MPRISHandler) CanPlay added in v0.5.0

func (m *MPRISHandler) CanPlay() (bool, error)

func (*MPRISHandler) CanQuit added in v0.5.0

func (m *MPRISHandler) CanQuit() (bool, error)

func (*MPRISHandler) CanRaise added in v0.5.0

func (m *MPRISHandler) CanRaise() (bool, error)

func (*MPRISHandler) CanSeek added in v0.5.0

func (m *MPRISHandler) CanSeek() (bool, error)

func (*MPRISHandler) HasTrackList added in v0.5.0

func (m *MPRISHandler) HasTrackList() (bool, error)

func (*MPRISHandler) Identity added in v0.5.0

func (m *MPRISHandler) Identity() (string, error)

func (*MPRISHandler) LoopStatus added in v0.5.0

func (m *MPRISHandler) LoopStatus() (types.LoopStatus, error)

func (*MPRISHandler) MaximumRate added in v0.5.0

func (m *MPRISHandler) MaximumRate() (float64, error)

func (*MPRISHandler) Metadata added in v0.5.0

func (m *MPRISHandler) Metadata() (types.Metadata, error)

func (*MPRISHandler) MinimumRate added in v0.5.0

func (m *MPRISHandler) MinimumRate() (float64, error)

func (*MPRISHandler) Next added in v0.5.0

func (m *MPRISHandler) Next() error

func (*MPRISHandler) OpenUri added in v0.5.0

func (m *MPRISHandler) OpenUri(uri string) error

func (*MPRISHandler) Pause added in v0.5.0

func (m *MPRISHandler) Pause() error

func (*MPRISHandler) Play added in v0.5.0

func (m *MPRISHandler) Play() error

func (*MPRISHandler) PlayPause added in v0.5.0

func (m *MPRISHandler) PlayPause() error

func (*MPRISHandler) PlaybackStatus added in v0.5.0

func (m *MPRISHandler) PlaybackStatus() (types.PlaybackStatus, error)

func (*MPRISHandler) Position added in v0.5.0

func (m *MPRISHandler) Position() (int64, error)

func (*MPRISHandler) Previous added in v0.5.0

func (m *MPRISHandler) Previous() error

func (*MPRISHandler) Quit added in v0.5.0

func (m *MPRISHandler) Quit() error

func (*MPRISHandler) Raise added in v0.5.0

func (m *MPRISHandler) Raise() error

func (*MPRISHandler) Rate added in v0.5.0

func (m *MPRISHandler) Rate() (float64, error)

func (*MPRISHandler) Seek added in v0.5.0

func (m *MPRISHandler) Seek(offset types.Microseconds) error

func (*MPRISHandler) SetLoopStatus added in v0.5.0

func (m *MPRISHandler) SetLoopStatus(status types.LoopStatus) error

func (*MPRISHandler) SetPosition added in v0.5.0

func (m *MPRISHandler) SetPosition(trackId string, position types.Microseconds) error

func (*MPRISHandler) SetRate added in v0.5.0

func (m *MPRISHandler) SetRate(float64) error

func (*MPRISHandler) SetVolume added in v0.5.0

func (m *MPRISHandler) SetVolume(v float64) error

func (*MPRISHandler) Shutdown added in v0.5.0

func (m *MPRISHandler) Shutdown()

Stops listening for MPRIS events and releases any D-Bus resources.

func (*MPRISHandler) Start added in v0.5.0

func (m *MPRISHandler) Start()

Starts listening for MPRIS events.

func (*MPRISHandler) Stop added in v0.5.0

func (m *MPRISHandler) Stop() error

func (*MPRISHandler) SupportedMimeTypes added in v0.5.0

func (m *MPRISHandler) SupportedMimeTypes() ([]string, error)

func (*MPRISHandler) SupportedUriSchemes added in v0.5.0

func (m *MPRISHandler) SupportedUriSchemes() ([]string, error)

func (*MPRISHandler) Volume added in v0.5.0

func (m *MPRISHandler) Volume() (float64, error)

type NowPlayingPageConfig

type NowPlayingPageConfig struct {
	InitialView string
}

type PeakMeterConfig added in v0.13.0

type PeakMeterConfig struct {
	WindowHeight int
	WindowWidth  int
}

type PlaybackConfig added in v0.14.0

type PlaybackConfig struct {
	Autoplay           bool
	RepeatMode         string
	UseWaveformSeekbar bool
}

type PlaybackManager

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

A high-level MediaProvider-aware playback engine, serves as an intermediary between the frontend and various Player backends.

func NewPlaybackManager

func NewPlaybackManager(
	ctx context.Context,
	s *ServerManager,
	c *AudioCache,
	p player.BasePlayer,
	playbackCfg *PlaybackConfig,
	scrobbleCfg *ScrobbleConfig,
	transcodeCfg *TranscodingConfig,
	appCfg *AppConfig,
) *PlaybackManager

func (*PlaybackManager) Continue added in v0.9.0

func (p *PlaybackManager) Continue()

func (*PlaybackManager) CurrentPlayer added in v0.9.0

func (p *PlaybackManager) CurrentPlayer() player.BasePlayer

func (*PlaybackManager) CurrentRemotePlayer added in v0.15.0

func (p *PlaybackManager) CurrentRemotePlayer() *RemotePlaybackDevice

func (*PlaybackManager) DisableCallbacks

func (p *PlaybackManager) DisableCallbacks()

Should only be called before quitting. Disables playback state callbacks being sent

func (*PlaybackManager) GetLoopMode added in v0.9.0

func (p *PlaybackManager) GetLoopMode() LoopMode

func (*PlaybackManager) GetPlayQueue

func (p *PlaybackManager) GetPlayQueue() []mediaprovider.MediaItem

func (*PlaybackManager) IsAutoplay added in v0.14.0

func (p *PlaybackManager) IsAutoplay() bool

func (*PlaybackManager) IsSeeking

func (p *PlaybackManager) IsSeeking() bool

func (*PlaybackManager) IsStopAfterCurrent added in v0.18.0

func (p *PlaybackManager) IsStopAfterCurrent() bool

func (*PlaybackManager) LoadAlbum

func (p *PlaybackManager) LoadAlbum(albumID string, insertQueueMode InsertQueueMode, shuffle bool) error

Loads the specified album into the play queue.

func (*PlaybackManager) LoadItems added in v0.12.0

func (p *PlaybackManager) LoadItems(items []mediaprovider.MediaItem, insertQueueMode InsertQueueMode, shuffle bool)

Load items into the play queue. If replacing the current queue (!appendToQueue), playback will be stopped.

func (*PlaybackManager) LoadPlaylist

func (p *PlaybackManager) LoadPlaylist(playlistID string, insertQueueMode InsertQueueMode, shuffle bool) error

Loads the specified playlist into the play queue.

func (*PlaybackManager) LoadRadioStation added in v0.11.0

func (p *PlaybackManager) LoadRadioStation(station *mediaprovider.RadioStation, queueMode InsertQueueMode)

func (*PlaybackManager) LoadTracks

func (p *PlaybackManager) LoadTracks(tracks []*mediaprovider.Track, insertQueueMode InsertQueueMode, shuffle bool)

Load tracks into the play queue. If replacing the current queue (!appendToQueue), playback will be stopped.

func (*PlaybackManager) NowPlaying

func (p *PlaybackManager) NowPlaying() mediaprovider.MediaItem

Gets the now playing media item, if any.

func (*PlaybackManager) NowPlayingIndex added in v0.4.0

func (p *PlaybackManager) NowPlayingIndex() int

func (*PlaybackManager) OnLoopModeChange added in v0.4.0

func (p *PlaybackManager) OnLoopModeChange(cb func(LoopMode))

Registers a callback that is notified whenever the loop mode changes.

func (*PlaybackManager) OnPaused added in v0.9.0

func (p *PlaybackManager) OnPaused(cb func())

Registers a callback that is notified whenever the player has been paused.

func (*PlaybackManager) OnPlayTimeUpdate

func (p *PlaybackManager) OnPlayTimeUpdate(cb func(curTime float64, totalTime float64, seeked bool))

Registers a callback that is notified whenever the play time should be updated.

func (*PlaybackManager) OnPlayerChange added in v0.9.0

func (p *PlaybackManager) OnPlayerChange(cb func())

func (*PlaybackManager) OnPlaying added in v0.9.0

func (p *PlaybackManager) OnPlaying(cb func())

Registers a callback that is notified whenever the player begins playing.

func (*PlaybackManager) OnQueueChange added in v0.10.0

func (p *PlaybackManager) OnQueueChange(cb func())

Registers a callback that is notified whenever the play queue changes.

func (*PlaybackManager) OnSeek added in v0.9.0

func (p *PlaybackManager) OnSeek(cb func())

Registers a callback that is notified whenever the player has been seeked.

func (*PlaybackManager) OnSongChange

func (p *PlaybackManager) OnSongChange(cb func(nowPlaying mediaprovider.MediaItem, justScrobbledIfAny *mediaprovider.Track))

Sets a callback that is notified whenever a new song begins playing.

func (*PlaybackManager) OnStopped added in v0.9.0

func (p *PlaybackManager) OnStopped(cb func())

Registers a callback that is notified whenever the player is stopped.

func (*PlaybackManager) OnTrackFavoriteStatusChanged

func (p *PlaybackManager) OnTrackFavoriteStatusChanged(id string, fav bool)

Any time the user changes the favorite status of a track elsewhere in the app, this should be called to ensure the in-memory track model is updated.

func (*PlaybackManager) OnTrackRatingChanged

func (p *PlaybackManager) OnTrackRatingChanged(id string, rating int)

Any time the user changes the rating of a track elsewhere in the app, this should be called to ensure the in-memory track model is updated.

func (*PlaybackManager) OnVolumeChange added in v0.5.0

func (p *PlaybackManager) OnVolumeChange(cb func(int))

Registers a callback that is notified whenever the volume changes.

func (*PlaybackManager) OnWaveformImgUpdate added in v0.18.0

func (p *PlaybackManager) OnWaveformImgUpdate(cb func(*WaveformImage))

func (*PlaybackManager) Pause added in v0.9.0

func (p *PlaybackManager) Pause()

func (*PlaybackManager) PlayAlbum

func (p *PlaybackManager) PlayAlbum(albumID string, firstTrack int, shuffle bool) error

func (*PlaybackManager) PlayArtistDiscography added in v0.12.0

func (p *PlaybackManager) PlayArtistDiscography(artistID string, shuffleTracks bool)

func (*PlaybackManager) PlayFromBeginning

func (p *PlaybackManager) PlayFromBeginning()

func (*PlaybackManager) PlayPause added in v0.9.0

func (p *PlaybackManager) PlayPause()

func (*PlaybackManager) PlayPlaylist

func (p *PlaybackManager) PlayPlaylist(playlistID string, firstTrack int, shuffle bool) error

func (*PlaybackManager) PlayRadioStation added in v0.12.0

func (p *PlaybackManager) PlayRadioStation(station *mediaprovider.RadioStation)

func (*PlaybackManager) PlayRandomAlbums added in v0.14.0

func (p *PlaybackManager) PlayRandomAlbums(genreName string) error

func (*PlaybackManager) PlayRandomSongs

func (p *PlaybackManager) PlayRandomSongs(genreName string) error

func (*PlaybackManager) PlaySimilarSongs

func (p *PlaybackManager) PlaySimilarSongs(id string) error

func (*PlaybackManager) PlayTrack added in v0.7.0

func (p *PlaybackManager) PlayTrack(trackID string) error

func (*PlaybackManager) PlayTrackAt

func (p *PlaybackManager) PlayTrackAt(idx int)

func (*PlaybackManager) PlaybackStatus added in v0.15.0

func (p *PlaybackManager) PlaybackStatus() PlaybackStatus

func (*PlaybackManager) RemotePlayers added in v0.15.0

func (p *PlaybackManager) RemotePlayers() []RemotePlaybackDevice

func (*PlaybackManager) RemoveTracksFromQueue

func (p *PlaybackManager) RemoveTracksFromQueue(idxs []int)

func (*PlaybackManager) ScanRemotePlayers added in v0.15.0

func (p *PlaybackManager) ScanRemotePlayers(ctx context.Context, fastScan bool)

func (*PlaybackManager) SeekBackOrPrevious added in v0.9.0

func (p *PlaybackManager) SeekBackOrPrevious()

func (*PlaybackManager) SeekBySeconds added in v0.12.0

func (p *PlaybackManager) SeekBySeconds(sec float64)

Seek by given relative position in the current track by seconds.

func (*PlaybackManager) SeekFraction added in v0.9.0

func (p *PlaybackManager) SeekFraction(fraction float64)

Seek to a fractional position in the current track [0..1]

func (*PlaybackManager) SeekNext added in v0.9.0

func (p *PlaybackManager) SeekNext()

func (*PlaybackManager) SeekSeconds added in v0.9.0

func (p *PlaybackManager) SeekSeconds(sec float64)

Seek to given absolute position in the current track by seconds.

func (*PlaybackManager) SetAutoplay added in v0.14.0

func (p *PlaybackManager) SetAutoplay(autoplay bool)

func (*PlaybackManager) SetLoopMode added in v0.5.0

func (p *PlaybackManager) SetLoopMode(loopMode LoopMode)

func (*PlaybackManager) SetNextLoopMode added in v0.4.0

func (p *PlaybackManager) SetNextLoopMode()

Changes the loop mode of the player to the next one. Useful for toggling UI elements, to change modes without knowing the current player mode.

func (*PlaybackManager) SetRemotePlayer added in v0.15.0

func (p *PlaybackManager) SetRemotePlayer(rp *RemotePlaybackDevice) error

func (*PlaybackManager) SetReplayGainMode added in v0.8.0

func (p *PlaybackManager) SetReplayGainMode(mode player.ReplayGainMode)

func (*PlaybackManager) SetReplayGainOptions

func (p *PlaybackManager) SetReplayGainOptions(config ReplayGainConfig)

func (*PlaybackManager) SetStopAfterCurrent added in v0.18.0

func (p *PlaybackManager) SetStopAfterCurrent(stopAfterCurrent bool)

func (*PlaybackManager) SetVolume added in v0.5.0

func (p *PlaybackManager) SetVolume(vol int)

func (*PlaybackManager) ShuffleArtistAlbums added in v0.12.0

func (p *PlaybackManager) ShuffleArtistAlbums(artistID string)

func (*PlaybackManager) Shutdown added in v0.15.0

func (p *PlaybackManager) Shutdown()

func (*PlaybackManager) Stop added in v0.9.0

func (p *PlaybackManager) Stop()

func (*PlaybackManager) StopAndClearPlayQueue

func (p *PlaybackManager) StopAndClearPlayQueue()

Stop playback and clear the play queue.

func (*PlaybackManager) UpdatePlayQueue added in v0.9.0

func (p *PlaybackManager) UpdatePlayQueue(items []mediaprovider.MediaItem)

Replaces the play queue with the given set of tracks. Does not stop playback if the currently playing track is in the new queue, but updates the now playing index to point to the first instance of the track in the new queue.

func (*PlaybackManager) Volume added in v0.5.0

func (p *PlaybackManager) Volume() int

type PlaybackState added in v0.15.0

type PlaybackState = player.State

type PlaybackStatus added in v0.15.0

type PlaybackStatus struct {
	State    PlaybackState
	TimePos  float64
	Duration float64
}

type PlaylistPageConfig

type PlaylistPageConfig struct {
	TracklistColumns []string
}

type PlaylistsPageConfig

type PlaylistsPageConfig struct {
	InitialView string
}

type RemotePlaybackDevice added in v0.15.0

type RemotePlaybackDevice struct {
	Name     string
	URL      string
	Protocol string
	// contains filtered or unexported fields
}

type ReplayGainConfig

type ReplayGainConfig struct {
	Mode            string
	PreampGainDB    float64
	PreventClipping bool
}

type SavedPlayQueue added in v0.9.0

type SavedPlayQueue struct {
	Tracks     []*mediaprovider.Track
	TrackIndex int
	TimePos    float64
}

func LoadPlayQueue added in v0.9.0

func LoadPlayQueue(filepath string, sm *ServerManager, loadFromServer bool) (*SavedPlayQueue, error)

Loads the saved play queue from the given filepath using the current server. If loadFromServer is true and the current server supports saving the play queue, the queue will attempt to load from the server and only use the local file as a fallback. Returns an error if the queue could not be loaded for any reason, including the currently logged in server being different than the server from which the queue was saved.

type ScrobbleConfig

type ScrobbleConfig struct {
	Enabled              bool
	ThresholdTimeSeconds int
	ThresholdPercent     int
}

type ServerConfig

type ServerConfig struct {
	ServerConnection
	ID       uuid.UUID
	Nickname string
	Default  bool
}

type ServerConnection

type ServerConnection struct {
	ServerType  ServerType
	Hostname    string
	AltHostname string
	Username    string
	LegacyAuth  bool
}

type ServerManager

type ServerManager struct {
	LoggedInUser string
	ServerID     uuid.UUID
	Server       mediaprovider.MediaProvider
	// contains filtered or unexported fields
}

func NewServerManager

func NewServerManager(appName, appVersion string, config *Config, useKeyring bool) *ServerManager

func (*ServerManager) AddServer

func (s *ServerManager) AddServer(nickname string, connection ServerConnection) *ServerConfig

func (*ServerManager) ConnectToServer

func (s *ServerManager) ConnectToServer(conf *ServerConfig, password string) error

func (*ServerManager) DeleteServer

func (s *ServerManager) DeleteServer(serverID uuid.UUID)

func (*ServerManager) GetDefaultServer

func (s *ServerManager) GetDefaultServer() *ServerConfig

func (*ServerManager) GetServer added in v0.18.0

func (a *ServerManager) GetServer() mediaprovider.MediaProvider

func (*ServerManager) GetServerPassword

func (s *ServerManager) GetServerPassword(serverID uuid.UUID) (string, error)

func (*ServerManager) Logout

func (s *ServerManager) Logout(deletePassword bool)

func (*ServerManager) OnLogout

func (s *ServerManager) OnLogout(cb func())

Sets a callback that is invoked when the user logs out of a server.

func (*ServerManager) OnServerConnected

func (s *ServerManager) OnServerConnected(cb func())

Sets a callback that is invoked when a server is connected to.

func (*ServerManager) SetDefaultServer

func (s *ServerManager) SetDefaultServer(serverID uuid.UUID)

func (*ServerManager) SetPrefetchAlbumCoverCallback

func (s *ServerManager) SetPrefetchAlbumCoverCallback(cb func(string))

func (*ServerManager) SetServerPassword

func (s *ServerManager) SetServerPassword(server *ServerConfig, password string) error

func (*ServerManager) TestConnectionAndAuth

func (s *ServerManager) TestConnectionAndAuth(
	ctx context.Context, connection ServerConnection, password string,
) error

type ServerType added in v0.8.0

type ServerType string
const (
	ServerTypeSubsonic ServerType = "Subsonic"
	ServerTypeJellyfin ServerType = "Jellyfin"
)

type ThemeConfig

type ThemeConfig struct {
	ThemeFile  string
	Appearance string
}

type TracksPageConfig

type TracksPageConfig struct {
	TracklistColumns []string
}

type TranscodingConfig added in v0.7.0

type TranscodingConfig struct {
	ForceRawFile     bool
	RequestTranscode bool
	Codec            string
	MaxBitRateKBPS   int
}

type UpdateChecker

type UpdateChecker struct {
	OnUpdatedVersionFound func()
	// contains filtered or unexported fields
}

A component to check for updates from the Github releases/latest URL.

func NewUpdateChecker

func NewUpdateChecker(appVersionTag, latestReleaseURL string, lastCheckedTag *string) UpdateChecker

func (*UpdateChecker) CheckLatestVersionTag

func (u *UpdateChecker) CheckLatestVersionTag() string

func (*UpdateChecker) LatestReleaseURL

func (u *UpdateChecker) LatestReleaseURL() *url.URL

func (*UpdateChecker) Start

func (u *UpdateChecker) Start(ctx context.Context, interval time.Duration)

Start automatically polling for updates in the background. Quits when the given ctx's Done channel returns a value.

func (*UpdateChecker) VersionTagFound

func (u *UpdateChecker) VersionTagFound() string

type WaveformImage added in v0.18.0

type WaveformImage = image.NRGBA

func NewWaveformImage added in v0.18.0

func NewWaveformImage() *WaveformImage

type WaveformImageGenerator added in v0.18.0

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

func NewWaveformImageGenerator added in v0.18.0

func NewWaveformImageGenerator(cache *AudioCache) *WaveformImageGenerator

func (*WaveformImageGenerator) StartWaveformGeneration added in v0.18.0

func (w *WaveformImageGenerator) StartWaveformGeneration(item *mediaprovider.Track) *WaveformImageJob

type WaveformImageJob added in v0.18.0

type WaveformImageJob struct {
	ItemID string
	// contains filtered or unexported fields
}

func (*WaveformImageJob) Cancel added in v0.18.0

func (w *WaveformImageJob) Cancel()

func (*WaveformImageJob) Canceled added in v0.18.0

func (w *WaveformImageJob) Canceled() bool

func (*WaveformImageJob) Done added in v0.18.0

func (w *WaveformImageJob) Done() bool

func (*WaveformImageJob) Err added in v0.18.0

func (w *WaveformImageJob) Err() error

func (*WaveformImageJob) Get added in v0.18.0

func (w *WaveformImageJob) Get() *WaveformImage

Directories

Path Synopsis
mpv

Jump to

Keyboard shortcuts

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