Documentation ¶
Index ¶
- Constants
- Variables
- type AlbumPageConfig
- type AlbumsPageConfig
- type App
- type AppConfig
- type ArtistPageConfig
- type CacheItem
- type Config
- type FavoritesPageConfig
- type ImageCache
- func (i *ImageCache) EvictExpired()
- func (i *ImageCache) Get(key string) (image.Image, error)
- func (i *ImageCache) GetExtendTTL(key string, ttl time.Duration) (image.Image, error)
- func (i *ImageCache) GetResetTTL(key string, resetTTL bool) (image.Image, error)
- func (i *ImageCache) GetWithNewTTL(key string, newTtl time.Duration) (image.Image, error)
- func (i *ImageCache) Has(key string) bool
- func (i *ImageCache) Init(ctx context.Context, evictionInterval time.Duration)
- func (i *ImageCache) Set(key string, val image.Image)
- func (i *ImageCache) SetWithTTL(key string, val image.Image, ttl time.Duration)
- type ImageManager
- func (i *ImageManager) FetchAndCacheArtistImage(artistID string, imgURL string) (image.Image, error)
- func (i *ImageManager) GetCachedArtistImage(artistID string) (image.Image, bool)
- func (i *ImageManager) GetCoverThumbnail(coverID string) (image.Image, error)
- func (i *ImageManager) GetCoverThumbnailFromCache(coverID string) (image.Image, bool)
- func (i *ImageManager) GetCoverThumbnailWithTTL(coverID string, ttl time.Duration) (image.Image, error)
- func (i *ImageManager) GetFullSizeCoverArt(coverID string) (image.Image, error)
- func (i *ImageManager) RefreshCachedArtistImageIfExpired(artistID string, imgURL string) error
- type LocalPlaybackConfig
- type NowPlayingPageConfig
- type PlaybackManager
- func (p *PlaybackManager) DisableCallbacks()
- func (p *PlaybackManager) GetPlayQueue() []*mediaprovider.Track
- func (p *PlaybackManager) IsSeeking() bool
- func (p *PlaybackManager) LoadAlbum(albumID string, appendToQueue bool, shuffle bool) error
- func (p *PlaybackManager) LoadPlaylist(playlistID string, appendToQueue bool, shuffle bool) error
- func (p *PlaybackManager) LoadTracks(tracks []*mediaprovider.Track, appendToQueue, shuffle bool) error
- func (p *PlaybackManager) NowPlaying() *mediaprovider.Track
- func (p *PlaybackManager) NowPlayingIndex() int
- func (p *PlaybackManager) OnLoopModeChange(cb func(string))
- func (p *PlaybackManager) OnPlayTimeUpdate(cb func(float64, float64))
- func (p *PlaybackManager) OnSongChange(...)
- func (p *PlaybackManager) OnTrackFavoriteStatusChanged(id string, fav bool)
- func (p *PlaybackManager) OnTrackRatingChanged(id string, rating int)
- func (p *PlaybackManager) PlayAlbum(albumID string, firstTrack int, shuffle bool) error
- func (p *PlaybackManager) PlayFromBeginning() error
- func (p *PlaybackManager) PlayPlaylist(playlistID string, firstTrack int, shuffle bool) error
- func (p *PlaybackManager) PlayRandomSongs(genreName string)
- func (p *PlaybackManager) PlaySimilarSongs(id string)
- func (p *PlaybackManager) PlayTrackAt(idx int) error
- func (p *PlaybackManager) RemoveTracksFromQueue(trackIDs []string)
- func (p *PlaybackManager) SetNextLoopMode() error
- func (p *PlaybackManager) SetReplayGainOptions(config ReplayGainConfig)
- func (p *PlaybackManager) StopAndClearPlayQueue()
- type PlaylistPageConfig
- type PlaylistsPageConfig
- type ReplayGainConfig
- type ScrobbleConfig
- type ServerConfig
- type ServerConnection
- type ServerManager
- func (s *ServerManager) AddServer(nickname string, connection ServerConnection) *ServerConfig
- func (s *ServerManager) ConnectToServer(conf *ServerConfig, password string) error
- func (s *ServerManager) DeleteServer(serverID uuid.UUID)
- func (s *ServerManager) GetDefaultServer() *ServerConfig
- func (s *ServerManager) GetServerPassword(serverID uuid.UUID) (string, error)
- func (s *ServerManager) Logout(deletePassword bool)
- func (s *ServerManager) OnLogout(cb func())
- func (s *ServerManager) OnServerConnected(cb func())
- func (s *ServerManager) SetDefaultServer(serverID uuid.UUID)
- func (s *ServerManager) SetPrefetchAlbumCoverCallback(cb func(string))
- func (s *ServerManager) SetServerPassword(server *ServerConfig, password string) error
- func (s *ServerManager) TestConnectionAndAuth(connection ServerConnection, password string, timeout time.Duration) error
- type ThemeConfig
- type TracksPageConfig
- type UpdateChecker
Constants ¶
const ( ReplayGainNone = string(player.ReplayGainNone) ReplayGainAlbum = string(player.ReplayGainAlbum) ReplayGainTrack = string(player.ReplayGainTrack) )
const CachedImageValidTime = 24 * time.Hour
Variables ¶
var ( ErrNoServers = errors.New("no servers set up") ErrAnotherInstance = errors.New("another instance is running") )
var (
ErrNotFound = errors.New("item not found")
)
var ErrUnreachable = errors.New("server is unreachable")
var SupportedStartupPages = []string{"Albums", "Favorites", "Playlists"}
Functions ¶
This section is empty.
Types ¶
type AlbumPageConfig ¶
type AlbumPageConfig struct {
TracklistColumns []string
}
type AlbumsPageConfig ¶
type AlbumsPageConfig struct {
SortOrder string
}
type App ¶
type App struct { Config *Config ServerManager *ServerManager ImageManager *ImageManager PlaybackManager *PlaybackManager Player *player.Player UpdateChecker UpdateChecker OnReactivate func() // contains filtered or unexported fields }
func StartupApp ¶
func (*App) LoginToDefaultServer ¶
func (*App) VersionTag ¶
type ArtistPageConfig ¶
type Config ¶
type Config struct { Application AppConfig Servers []*ServerConfig AlbumPage AlbumPageConfig AlbumsPage AlbumsPageConfig ArtistPage ArtistPageConfig FavoritesPage FavoritesPageConfig NowPlayingPage NowPlayingPageConfig PlaylistPage PlaylistPageConfig PlaylistsPage PlaylistsPageConfig TracksPage TracksPageConfig LocalPlayback LocalPlaybackConfig Scrobbling ScrobbleConfig ReplayGain ReplayGainConfig Theme ThemeConfig }
func DefaultConfig ¶
func ReadConfigFile ¶
func (*Config) WriteConfigFile ¶
type FavoritesPageConfig ¶
type ImageCache ¶
type ImageCache struct { MinSize int MaxSize int DefaultTTL time.Duration // contains filtered or unexported fields }
A custom in-memory cache for images with the following eviction strategy:
- If there are fewer than MinSize items in the cache, none will be evicted
- 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
- 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) 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) GetExtendTTL ¶
Gets the image if it exists and extends TTL to time.Now + ttl iff the image would expire before then
func (*ImageCache) GetResetTTL ¶
func (*ImageCache) GetWithNewTTL ¶
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) SetWithTTL ¶
holds writer lock for O(i.MaxSize) worst case
type ImageManager ¶
type ImageManager struct {
// contains filtered or unexported fields
}
func NewImageManager ¶
func NewImageManager(ctx context.Context, s *ServerManager, baseCacheDir string) *ImageManager
func (*ImageManager) FetchAndCacheArtistImage ¶
func (*ImageManager) GetCachedArtistImage ¶
func (i *ImageManager) GetCachedArtistImage(artistID string) (image.Image, bool)
func (*ImageManager) GetCoverThumbnail ¶
func (i *ImageManager) GetCoverThumbnail(coverID string) (image.Image, error)
func (*ImageManager) GetCoverThumbnailFromCache ¶
func (i *ImageManager) GetCoverThumbnailFromCache(coverID string) (image.Image, bool)
func (*ImageManager) GetCoverThumbnailWithTTL ¶
func (*ImageManager) GetFullSizeCoverArt ¶
func (i *ImageManager) GetFullSizeCoverArt(coverID string) (image.Image, error)
func (*ImageManager) RefreshCachedArtistImageIfExpired ¶
func (i *ImageManager) RefreshCachedArtistImageIfExpired(artistID string, imgURL string) error
type LocalPlaybackConfig ¶
type NowPlayingPageConfig ¶
type NowPlayingPageConfig struct {
TracklistColumns []string
}
type PlaybackManager ¶
type PlaybackManager struct {
// contains filtered or unexported fields
}
A high-level Subsonic-aware playback backend. Manages loading tracks into the Player queue, sending callbacks on play time updates and track changes.
func NewPlaybackManager ¶
func NewPlaybackManager( ctx context.Context, s *ServerManager, p *player.Player, scrobbleCfg *ScrobbleConfig, ) *PlaybackManager
func (*PlaybackManager) DisableCallbacks ¶
func (p *PlaybackManager) DisableCallbacks()
Should only be called before quitting. Disables playback state callbacks being sent
func (*PlaybackManager) GetPlayQueue ¶
func (p *PlaybackManager) GetPlayQueue() []*mediaprovider.Track
func (*PlaybackManager) IsSeeking ¶
func (p *PlaybackManager) IsSeeking() bool
func (*PlaybackManager) LoadAlbum ¶
func (p *PlaybackManager) LoadAlbum(albumID string, appendToQueue bool, shuffle bool) error
Loads the specified album into the play queue.
func (*PlaybackManager) LoadPlaylist ¶
func (p *PlaybackManager) LoadPlaylist(playlistID string, appendToQueue bool, shuffle bool) error
Loads the specified playlist into the play queue.
func (*PlaybackManager) LoadTracks ¶
func (p *PlaybackManager) LoadTracks(tracks []*mediaprovider.Track, appendToQueue, shuffle bool) error
func (*PlaybackManager) NowPlaying ¶
func (p *PlaybackManager) NowPlaying() *mediaprovider.Track
Gets the curently playing song, 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(string))
Registers a callback that is notified whenever the loop mode changes.
func (*PlaybackManager) OnPlayTimeUpdate ¶
func (p *PlaybackManager) OnPlayTimeUpdate(cb func(float64, float64))
Registers a callback that is notified whenever the play time should be updated.
func (*PlaybackManager) OnSongChange ¶
func (p *PlaybackManager) OnSongChange(cb func(nowPlaying *mediaprovider.Track, justScrobbledIfAny *mediaprovider.Track))
Sets a callback that is notified whenever a new song begins playing.
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) PlayAlbum ¶
func (p *PlaybackManager) PlayAlbum(albumID string, firstTrack int, shuffle bool) error
func (*PlaybackManager) PlayFromBeginning ¶
func (p *PlaybackManager) PlayFromBeginning() error
func (*PlaybackManager) PlayPlaylist ¶
func (p *PlaybackManager) PlayPlaylist(playlistID string, firstTrack int, shuffle bool) error
func (*PlaybackManager) PlayRandomSongs ¶
func (p *PlaybackManager) PlayRandomSongs(genreName string)
func (*PlaybackManager) PlaySimilarSongs ¶
func (p *PlaybackManager) PlaySimilarSongs(id string)
func (*PlaybackManager) PlayTrackAt ¶
func (p *PlaybackManager) PlayTrackAt(idx int) error
func (*PlaybackManager) RemoveTracksFromQueue ¶
func (p *PlaybackManager) RemoveTracksFromQueue(trackIDs []string)
func (*PlaybackManager) SetNextLoopMode ¶ added in v0.4.0
func (p *PlaybackManager) SetNextLoopMode() error
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) SetReplayGainOptions ¶
func (p *PlaybackManager) SetReplayGainOptions(config ReplayGainConfig)
func (*PlaybackManager) StopAndClearPlayQueue ¶
func (p *PlaybackManager) StopAndClearPlayQueue()
Stop playback and clear the play queue.
type PlaylistPageConfig ¶
type PlaylistPageConfig struct {
TracklistColumns []string
}
type PlaylistsPageConfig ¶
type PlaylistsPageConfig struct {
InitialView string
}
type ReplayGainConfig ¶
type ScrobbleConfig ¶
type ServerConfig ¶
type ServerConfig struct { ServerConnection ID uuid.UUID Nickname string Default bool }
type ServerConnection ¶
type ServerManager ¶
type ServerManager struct { LoggedInUser string ServerID uuid.UUID Server mediaprovider.MediaProvider // contains filtered or unexported fields }
func NewServerManager ¶
func NewServerManager(appName string, config *Config) *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) 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( connection ServerConnection, password string, timeout time.Duration, ) error
type ThemeConfig ¶
type TracksPageConfig ¶
type TracksPageConfig struct {
TracklistColumns []string
}
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