Documentation ¶
Index ¶
- Constants
- Variables
- func AsciiRender(filepath string, flags aic_package.Flags) string
- func MainControlsRender(view string) string
- func RenderDeviceView(dv *DeviceView, device *player.Device) string
- type DeviceListModel
- type DeviceView
- type Item
- type Model
- type PlayerView
- type PlaylistListModel
- type PlaylistView
- type SearchTypeListModel
- type SearchTypeView
- type Terminal
Constants ¶
View Source
const ( LIST_HEIGHT = 10 DEFAULT_WIDTH = 40 DEFAULT_LIST_HEIGHT = 20 // 7 Selections per page SMALL_LIST_HEIGHT = 9 // 5 Selections per page )
View Source
const ( MIN_TERMINAL_HEIGHT = 21 MIN_TERMINAL_WIDTH = 38 )
View Source
const ( PLAYER_VIEW = "PLAYER_VIEW" PLAYLIST_VIEW = "PLAYLIST_VIEW" PLAYLIST_TRACK_VIEW = "PLAYLIST_TRACK_VIEW" ALBUM_TRACK_VIEW = "ALBUM_TRACK_VIEW" REFRESH_VIEW = "REFRESH_VIEW" HELP_VIEW = "HELP_VIEW" TERMINAL_WARNING_VIEW = "TERMINAL_WARNING_VIEW" SEARCH_TYPE_VIEW = "SEARCH_TYPE_VIEW" SEARCH_QUERY_VIEW = "SEARCH_QUERY_VIEW" SEARCH_PLAYLIST_VIEW = "SEARCH_PLAYLIST_VIEW" SEARCH_TRACK_VIEW = "SEARCH_TRACK_VIEW" SEARCH_ALBUM_VIEW = "SEARCH_ALBUM_VIEW" DEVICE_VIEW = "DEVICE_VIEW" )
View Source
const ( POLLING_RATE_MS = 500 * time.Millisecond VOLUME_INCREMENT_PERCENT = 5 )
View Source
const ( PAUSED = "Paused" NO_PLAYER = "Player Inactive" NOW_PLAYING = "Now Playing" )
View Source
const TAB_WIDTH = 4
Variables ¶
View Source
var ASCII_FLAGS_NORMAL aic_package.Flags = func() aic_package.Flags { flags := aic_package.DefaultFlags() flags.Colored = true flags.Dimensions = []int{40, 20} flags.Braille = true flags.Threshold = 20 return flags }()
View Source
var ASCII_FLAGS_SMALL aic_package.Flags = func() aic_package.Flags { flags := aic_package.DefaultFlags() flags.Colored = true flags.Dimensions = []int{20, 10} flags.Braille = true flags.Threshold = 20 return flags }()
View Source
var CommonStyle = struct { MainControls struct { Selected lg.Style Normal lg.Style } }{ MainControls: struct { Selected lg.Style Normal lg.Style }{ Normal: lg.NewStyle().Faint(true), Selected: lg.NewStyle(), }, }
View Source
var DeviceViewStyle = struct { Title lg.Style ItemSelected lg.Style Item lg.Style }{ Title: lg.NewStyle().Bold(true).Background(lg.Color("#a89984")).Foreground(lg.Color("#282828")).PaddingLeft(1).PaddingRight(1), ItemSelected: lg.NewStyle().PaddingLeft(2), Item: lg.NewStyle().PaddingLeft(4).Faint(true), }
View Source
var PlayerInfoView = func(pv *PlayerView) string { if pv.State == nil { return "invalid player state" } track, artist, progressMin, progressSec, durationMin, durationSec := pv.State.Track.InfoString(pv.Config, pv.ProgressMs) var shuffle string if pv.State.ShuffleState { shuffle = "on" } else { shuffle = "off" } return padLines(fmt.Sprintf( "%s - %s\n\n%sm:%ss / %sm:%ss\n\nvol: %v%% sfl: %v", track, artist, progressMin, progressSec, durationMin, durationSec, pv.State.Device.VolumePercent, shuffle, ), TAB_WIDTH) }
View Source
var PlayerStatusView = func(pv *PlayerView) string {
return padLines(pv.PlayingStatusStyle.Render(pv.PlayingStatus), 4)
}
View Source
var PlayerViewStyle = struct { StatusBar struct { NowPlaying lg.Style Paused lg.Style NoPlayer lg.Style } }{ StatusBar: struct { NowPlaying lg.Style Paused lg.Style NoPlayer lg.Style }{ NowPlaying: lg.NewStyle(). Bold(true). Foreground(lg.Color("#282828")). Background(lg.Color("#98971a")). PaddingLeft(1). PaddingRight(1), Paused: lg.NewStyle(). Bold(true). Foreground(lg.Color("#282828")). Background(lg.Color("#d79921")). PaddingLeft(1). PaddingRight(1), NoPlayer: lg.NewStyle(). Bold(true). Foreground(lg.Color("#282828")). Background(lg.Color("#cc241d")). PaddingLeft(1). PaddingRight(1), }, }
View Source
var PlaylistViewStyle = struct { Title lg.Style ItemSelected lg.Style Item lg.Style }{ Title: lg.NewStyle().Bold(true).Background(lg.Color("#a89984")).Foreground(lg.Color("#282828")).PaddingLeft(1).PaddingRight(1), ItemSelected: lg.NewStyle().PaddingLeft(2), Item: lg.NewStyle().PaddingLeft(4).Faint(true), }
View Source
var TERMINALSIZE = struct { Small int Normal int }{ Small: 30, Normal: 40, }
The minimum terminal size to be considered small or normal.
Functions ¶
func AsciiRender ¶
func AsciiRender(filepath string, flags aic_package.Flags) string
func MainControlsRender ¶
func RenderDeviceView ¶
func RenderDeviceView(dv *DeviceView, device *player.Device) string
Renders the list of devices, and current device information in a single row, two column table.
Types ¶
type DeviceListModel ¶
type DeviceListModel struct {
// contains filtered or unexported fields
}
func NewDeviceListModel ¶
func NewDeviceListModel(items []list.Item) *DeviceListModel
func (DeviceListModel) Init ¶
func (_ DeviceListModel) Init() tea.Cmd
func (DeviceListModel) View ¶
func (dlm DeviceListModel) View() string
type DeviceView ¶
type DeviceView struct { Session *auth.Session ListModel *DeviceListModel // contains filtered or unexported fields }
func NewDeviceView ¶
func NewDeviceView(s *auth.Session) *DeviceView
Creates a new device view with a list model for the user to select available playback devices.
func (*DeviceView) GetDeviceFromChoice ¶
func (dv *DeviceView) GetDeviceFromChoice(choice string) *player.Device
func (*DeviceView) GetSelectedDevice ¶
func (dv *DeviceView) GetSelectedDevice() *player.Device
func (*DeviceView) UpdateDevices ¶
func (dv *DeviceView) UpdateDevices()
type Model ¶
type Model struct { Session *auth.Session Player *player.Player Config *config.Config CurrentView string Views struct { // Tracks player state and current progress, // displaying information in a media player. Player *PlayerView Playlist *PlaylistView SearchType *SearchTypeView Device *DeviceView } Terminal Terminal CurrentWarning string }
type PlayerView ¶
type PlayerView struct { Session *auth.Session Player *player.Player Config *config.Config State *player.PlayerState // The title status bar indicating, playing, paused or invalid device. PlayingStatus string PlayingStatusStyle *lipgloss.Style // Tracks time independent of state progress // to improve performance, periodically will // be checked for error. ProgressMs int // Kept to track if progressMs is in sync with the song. TrackID string }
func NewPlayerView ¶
func (*PlayerView) EnsureProgressSynced ¶
func (pv *PlayerView) EnsureProgressSynced()
Ensures that player time progress is within 2 * polling rate.
func (*PlayerView) PlayPause ¶
func (pv *PlayerView) PlayPause()
func (*PlayerView) UpdateStateAsync ¶
func (pv *PlayerView) UpdateStateAsync()
Updates state asyncchronously to improve progress timer smoothness.
func (*PlayerView) UpdateStateSync ¶
func (pv *PlayerView) UpdateStateSync()
Update state synchronously for percision.
func (*PlayerView) View ¶
func (pv *PlayerView) View(terminal Terminal) string
type PlaylistListModel ¶
type PlaylistListModel struct {
// contains filtered or unexported fields
}
func NewPlaylistListModel ¶
func NewPlaylistListModel(items []list.Item, title string) *PlaylistListModel
func (PlaylistListModel) Init ¶
func (m PlaylistListModel) Init() tea.Cmd
func (PlaylistListModel) View ¶
func (m PlaylistListModel) View() string
type PlaylistView ¶
type PlaylistView struct { Session *auth.Session Config *config.Config UserPlaylists *[]spotify.Playlist ItemsMap map[list.Item]string PlaylistListModel *PlaylistListModel // contains filtered or unexported fields }
func NewPlaylistView ¶
func NewPlaylistView(s *auth.Session, c *config.Config) *PlaylistView
func (*PlaylistView) GetPlaylistFromChoice ¶
func (pv *PlaylistView) GetPlaylistFromChoice(choice string) *spotify.Playlist
func (*PlaylistView) GetSelectedName ¶
func (pv *PlaylistView) GetSelectedName() string
func (*PlaylistView) GetSelectedPlaylist ¶
func (pv *PlaylistView) GetSelectedPlaylist() *spotify.Playlist
func (*PlaylistView) View ¶
func (pv *PlaylistView) View(playerView *PlayerView, terminal Terminal) string
type SearchTypeListModel ¶
type SearchTypeListModel struct {
// contains filtered or unexported fields
}
func NewSearchTypeListModel ¶
func NewSearchTypeListModel(items []list.Item) *SearchTypeListModel
func (SearchTypeListModel) Init ¶
func (m SearchTypeListModel) Init() tea.Cmd
func (SearchTypeListModel) View ¶
func (m SearchTypeListModel) View() string
type SearchTypeView ¶
type SearchTypeView struct { Session *auth.Session ListModel *SearchTypeListModel Types []string }
func NewSearchTypeView ¶
func NewSearchTypeView(s *auth.Session) *SearchTypeView
func (*SearchTypeView) View ¶
func (st *SearchTypeView) View(playerView *PlayerView, terminal Terminal) string
Click to show internal directories.
Click to hide internal directories.