-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from jmillerv/local-folder
Implement Local Folder Functionality
- Loading branch information
Showing
5 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,6 @@ import ( | |
"time" | ||
) | ||
|
||
// Not yet implemented | ||
|
||
type LocalFile struct { | ||
Name string | ||
Content *os.File | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package content | ||
|
||
import ( | ||
log "github.com/sirupsen/logrus" | ||
"io/fs" | ||
"io/ioutil" | ||
) | ||
|
||
// The folder structure exists because I didn't want to load an entire folder's worth | ||
// of songs into memory like the LocalFile struct does. | ||
|
||
// Folder is a struct for parsing folders that implements the Media interface | ||
type Folder struct { | ||
Name string | ||
Content *[]fs.FileInfo | ||
Path string | ||
} | ||
|
||
func (f *Folder) Get() { | ||
log.Infof("buffering files from %s", f.Path) | ||
folder, err := ioutil.ReadDir(f.Path) | ||
if err != nil { | ||
log.WithError(err).Error("unable to read folder from path") | ||
} | ||
f.Content = &folder | ||
} | ||
|
||
func (f *Folder) Play() { | ||
// loop through the folder and play each as a local file | ||
for _, file := range *f.Content { | ||
l := f.getLocalFile(file) | ||
l.Play() | ||
} | ||
|
||
panic("implement me") | ||
} | ||
|
||
func (f *Folder) Stop() { | ||
panic("implement me") | ||
} | ||
|
||
func (f *Folder) getLocalFile(file fs.FileInfo) *LocalFile { | ||
l := &LocalFile{ | ||
Name: file.Name(), | ||
Path: f.Path + "/" + file.Name(), | ||
} | ||
l.Get() | ||
return l | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters