In Playlist a method Load() was renamed into load(), and a public Reload() method created.
This commit is contained in:
parent
9f361be6c4
commit
4faf2a0309
@ -19,7 +19,7 @@ type Playlist struct {
|
|||||||
// Returns an error if failed to load a playlist file.
|
// Returns an error if failed to load a playlist file.
|
||||||
func NewPlaylist(filePath string, repeat bool) (*Playlist, error) {
|
func NewPlaylist(filePath string, repeat bool) (*Playlist, error) {
|
||||||
p := &Playlist{filePath: filePath, repeat: repeat}
|
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
|
// 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load reads a playlist file and fills.
|
// Load reads a playlist file.
|
||||||
func (p *Playlist) Load() error {
|
func (p *Playlist) load() error {
|
||||||
data, err := os.ReadFile(p.filePath)
|
data, err := os.ReadFile(p.filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -54,3 +54,7 @@ func (p *Playlist) Load() error {
|
|||||||
p.mut.Unlock()
|
p.mut.Unlock()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Playlist) Reload() error {
|
||||||
|
return p.load()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user