backend

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: GPL-3.0 Imports: 44 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 (
	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 InitMPMediaHandler added in v0.6.0

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

func NewPlaybackEngine added in v0.9.0

func NewPlaybackEngine(
	ctx context.Context,
	s *ServerManager,
	p player.BasePlayer,
	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.

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
	LocalPlayer     *mpv.Player
	UpdateChecker   UpdateChecker
	MPRISHandler    *MPRISHandler

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

func StartupApp

func StartupApp(appName, displayAppName, appVersionTag, configFile, 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) LoadSavedPlayQueue added in v0.9.0

func (a *App) LoadSavedPlayQueue() error

func (*App) LoginToDefaultServer

func (a *App) LoginToDefaultServer(string) error

func (*App) SaveConfigFile added in v0.8.0

func (a *App) SaveConfigFile()

func (*App) Shutdown

func (a *App) Shutdown()

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
	ShowTrackChangeNotification bool

	// Experimental - may be removed in future
	FontNormalTTF string
	FontBoldTTF   string
	UIScaleSize   string
}

type ArtistPageConfig

type ArtistPageConfig struct {
	InitialView      string
	TracklistColumns []string
}

type ArtistsPageConfig added in v0.10.0

type ArtistsPageConfig struct {
	SortOrder string
}

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
	PlaylistPage     PlaylistPageConfig
	PlaylistsPage    PlaylistsPageConfig
	TracksPage       TracksPageConfig
	NowPlayingConfig NowPlayingPageConfig
	LocalPlayback    LocalPlaybackConfig
	Scrobbling       ScrobbleConfig
	ReplayGain       ReplayGainConfig
	Transcoding      TranscodingConfig
	Theme            ThemeConfig
}

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
}

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) 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) GetCoverThumbnailWithTTL

func (i *ImageManager) GetCoverThumbnailWithTTL(coverID string, ttl time.Duration) (image.Image, error)

GetCoverThumbnailWithTTL fetches the cover for the given coverID and updates the TTL in the in-memory image cache. It blocks until the image fetch is complete.

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 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 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,
	p player.BasePlayer,
	scrobbleCfg *ScrobbleConfig,
	transcodeCfg *TranscodingConfig,
) *PlaybackManager

func (*PlaybackManager) Continue added in v0.9.0

func (p *PlaybackManager) Continue() error

func (*PlaybackManager) CurrentPlayer added in v0.9.0

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

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.Track

func (*PlaybackManager) IsSeeking

func (p *PlaybackManager) IsSeeking() 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) LoadPlaylist

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

Loads the specified playlist into the play queue.

func (*PlaybackManager) LoadTracks

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

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

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(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(float64, float64))

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.Track, 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) Pause added in v0.9.0

func (p *PlaybackManager) Pause() error

func (*PlaybackManager) PlayAlbum

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

func (*PlaybackManager) PlayFromBeginning

func (p *PlaybackManager) PlayFromBeginning() error

func (*PlaybackManager) PlayPause added in v0.9.0

func (p *PlaybackManager) PlayPause() 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) PlayTrack added in v0.7.0

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

func (*PlaybackManager) PlayTrackAt

func (p *PlaybackManager) PlayTrackAt(idx int) error

func (*PlaybackManager) PlayerStatus added in v0.9.0

func (p *PlaybackManager) PlayerStatus() player.Status

func (*PlaybackManager) RemoveTracksFromQueue

func (p *PlaybackManager) RemoveTracksFromQueue(trackIDs []string)

func (*PlaybackManager) SeekBackOrPrevious added in v0.9.0

func (p *PlaybackManager) SeekBackOrPrevious() error

func (*PlaybackManager) SeekFraction added in v0.9.0

func (p *PlaybackManager) SeekFraction(fraction float64) error

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

func (*PlaybackManager) SeekNext added in v0.9.0

func (p *PlaybackManager) SeekNext() error

func (*PlaybackManager) SeekSeconds added in v0.9.0

func (p *PlaybackManager) SeekSeconds(sec float64) error

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

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) SetReplayGainMode added in v0.8.0

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

func (*PlaybackManager) SetReplayGainOptions

func (p *PlaybackManager) SetReplayGainOptions(config ReplayGainConfig)

func (*PlaybackManager) SetVolume added in v0.5.0

func (p *PlaybackManager) SetVolume(vol int) error

func (*PlaybackManager) Stop added in v0.9.0

func (p *PlaybackManager) Stop() error

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(tracks []*mediaprovider.Track) error

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 PlaylistPageConfig

type PlaylistPageConfig struct {
	TracklistColumns []string
}

type PlaylistsPageConfig

type PlaylistsPageConfig struct {
	InitialView string
}

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 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(
	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
}

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

Directories

Path Synopsis
mpv

Jump to

Keyboard shortcuts

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