1
0

In Playlist a method Load() was renamed into load(), and a public Reload() method created.

This commit is contained in:
Alexander Andreev 2023-10-01 06:40:05 +04:00
parent 9f361be6c4
commit 4faf2a0309
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -19,7 +19,7 @@ type Playlist struct {
// Returns an error if failed to load a playlist file.
func NewPlaylist(filePath string, repeat bool) (*Playlist, error) {
p := &Playlist{filePath: filePath, repeat: repeat}
return p, p.Load()
return p, p.load()
}
// Next returns the next song to play. Returns an empty string if repeat is
@ -42,8 +42,8 @@ func (p *Playlist) Next() (song string) {
return
}
// Load reads a playlist file and fills.
func (p *Playlist) Load() error {
// Load reads a playlist file.
func (p *Playlist) load() error {
data, err := os.ReadFile(p.filePath)
if err != nil {
return err
@ -54,3 +54,7 @@ func (p *Playlist) Load() error {
p.mut.Unlock()
return nil
}
func (p *Playlist) Reload() error {
return p.load()
}