Documentation ¶
Index ¶
- type Playlist
- type PlaylistName
- type RepeatMode
- type State
- func (s *State) AddPlaylist(p *playlist.Playlist) *Playlist
- func (s *State) AutoNext() (int, *Track)
- func (s *State) DeletePlaylist(name string)
- func (s *State) IsMuted() bool
- func (s *State) IsShuffling() bool
- func (s *State) MarkChanged()
- func (s *State) MarshalJSON() ([]byte, error)
- func (s *State) Next() (int, *Track)
- func (s *State) NowPlaying() (int, *Track)
- func (s *State) OnUpdate(fn func(*State))
- func (s *State) Peek() (int, *Track)
- func (s *State) Play(index int) *Track
- func (s *State) PlayingPlaylist() *Playlist
- func (s *State) PlayingPlaylistName() string
- func (s *State) Playlist(name string) (*Playlist, bool)
- func (s *State) PlaylistFromPath(path string) (*Playlist, bool)
- func (s *State) PlaylistNames() []PlaylistName
- func (s *State) Previous() (int, *Track)
- func (s *State) RefreshQueue()
- func (s *State) ReloadPlayQueue()
- func (s *State) RenamePlaylist(p *Playlist, oldName string)
- func (s *State) RepeatMode() RepeatMode
- func (s *State) SaveAll()
- func (s *State) SaveState()
- func (s *State) SetMute(muted bool)
- func (s *State) SetPlayingPlaylist(pl *Playlist)
- func (s *State) SetRepeatMode(mode RepeatMode)
- func (s *State) SetShuffling(shuffling bool)
- func (s *State) SetVolume(vol float64)
- func (s *State) UnmarshalJSON(b []byte) error
- func (s *State) Volume() float64
- func (s *State) WaitUntilSaved()
- type Track
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Playlist ¶
type Playlist struct { Name PlaylistName Path string Tracks []*Track // contains filtered or unexported fields }
func (*Playlist) Add ¶
Add adds the given path to a track to the current playlist. It marks the playlist as unsaved. If before is false, then the track is appended after the index. If before is true, then the track is appended before the index. The returned integers are the positions of the inserted tracks. If len(paths) is 0, then ix is returned for both.
func (*Playlist) Remove ¶
Remove removes the tracks with the given indices. The function guarantees that the delete will never touch tracks that didn't have the given indices before removal; it does this by sorting the internal array of ixs.
func (*Playlist) Save ¶
Save saves the playlist. The function must not be called in another goroutine. The done callback may be called in a goroutine.
TODO: refactor this to Save() and WaitUntilSaved().
func (*Playlist) SetUnsaved ¶
func (pl *Playlist) SetUnsaved()
SetUnsaved marks the playlist as unsaved.
type PlaylistName ¶
type PlaylistName = string
type RepeatMode ¶
type RepeatMode uint8
const ( RepeatNone RepeatMode = iota RepeatAll RepeatSingle )
func (RepeatMode) Cycle ¶
func (m RepeatMode) Cycle() RepeatMode
Cycle returns the next mode to be activated when the repeat button is constantly pressed.
type State ¶
type State struct {
// contains filtered or unexported fields
}
func ReadFromFile ¶
ReadFromFile reads the state from the user's state.
func (*State) AddPlaylist ¶
AddPlaylist adds a playlist. If a playlist with the same name is added, then the function does nothing.
func (*State) AutoNext ¶
AutoNext returns the next track, unless we're in RepeatSingle mode, then it returns the same track. Use this to cycle across the playlist.
func (*State) DeletePlaylist ¶
DeletePlaylist deletes the playlist with the given name.
func (*State) IsShuffling ¶
IsShuffling returns true if the list is being shuffled.
func (*State) MarkChanged ¶
func (s *State) MarkChanged()
MarkChanged marks the state as changed (unsaved).
func (*State) MarshalJSON ¶
MarshalJSON marshals State to JSON.
func (*State) Next ¶
Next returns the next track from the currently playing playlist. Nil is returned if there is no next track.
func (*State) NowPlaying ¶
NowPlaying returns the currently playing track. If playingPl is nil, then this method returns (-1, nil).
func (*State) OnUpdate ¶
OnTrackUpdate adds into the call stack a callback that is triggered when the state is changed.
func (*State) Peek ¶
Peek returns the next track without changing the state. It basically emulates AutoNext.
func (*State) Play ¶
Play plays the track indexed relative to the actual playlist. This does not index relative to the actual play queue, which may be shuffled. It also does not update QueuePos if we're shuffling.
func (*State) PlayingPlaylist ¶
PlayingPlaylist returns the playing playlist, or nil if none. It panics if the internal states are inconsistent, which should never happen unless the playlist pointer was illegally changed. If the path were to be changed, then SetCurrentPlaylist should be called again.
func (*State) PlayingPlaylistName ¶
PlayingPlaylistName returns the playing playlist name, or an empty string if none.
func (*State) Playlist ¶
Playlist returns a playlist, or nil if none. It also returns a boolean to indicate.
func (*State) PlaylistFromPath ¶
PlaylistFromPath returns a playlist, or nil if none.
func (*State) PlaylistNames ¶
func (s *State) PlaylistNames() []PlaylistName
func (*State) Previous ¶
Previous returns the previous track, similarly to Next. Nil is returned if there is no previous track. If shuffling mode is on, then Prev will not return the previous track.
func (*State) RefreshQueue ¶
func (s *State) RefreshQueue()
RefreshQueue refreshes completely the current play queue.
func (*State) ReloadPlayQueue ¶
func (s *State) ReloadPlayQueue()
ReloadPlayQueue reloads the internal play queue for the currently playing playlist. Call this when the playlist's track slice is changed.
func (*State) RenamePlaylist ¶
func (*State) RepeatMode ¶
func (s *State) RepeatMode() RepeatMode
RepeatMode returns the current repeat mode.
func (*State) SaveAll ¶
func (s *State) SaveAll()
SaveAll saves the state and all its playlists. It's asynchronous.
func (*State) SaveState ¶
func (s *State) SaveState()
SaveState saves the state. It is non-blocking, but the JSON is marshaled in the same thread as the caller.
func (*State) SetPlayingPlaylist ¶
SetPlayingPlaylist sets the playing playlist.
func (*State) SetRepeatMode ¶
func (s *State) SetRepeatMode(mode RepeatMode)
SetRepeatMode sets the current repeat mode.
func (*State) SetShuffling ¶
SetShuffling sets the shuffling mode.
func (*State) UnmarshalJSON ¶
func (*State) WaitUntilSaved ¶
func (s *State) WaitUntilSaved()
WaitUntilSaved waits until all the saving routines are done. This is useful for implementing a loading bar.
type Track ¶
type Track struct { Filepath string // contains filtered or unexported fields }
Track is a track value that keeps track of a Metadata pointer and a filepath.
func (*Track) Metadata ¶
Metadata returns a copy of the current track's metadata with the filepath filled in. If the metadata is not found, then a placeholder one is returned.
func (*Track) UpdateMetadata ¶
UpdateMetadata updates the track's metadata in the global metadata store. If the metadata does not yet exist, it will create a new one and automatically reference it. Else, no references are taken.