diff --git a/internal/stream/file.go b/internal/stream/file.go index d8f93f6d..cfaa5292 100644 --- a/internal/stream/file.go +++ b/internal/stream/file.go @@ -13,27 +13,23 @@ import ( "github.com/gabe565/relax-sounds/internal/util" ) -type File struct { - fs.File -} - var ErrUnsupportedFileType = errors.New("unsupported file type") -func (f File) Decode() (beep.StreamSeekCloser, beep.Format, error) { - contentType, err := util.GetTypeFromFile(f.File) +func Decode(f fs.File) (beep.StreamSeekCloser, beep.Format, error) { + contentType, err := util.GetTypeFromFile(f) if err != nil { return nil, beep.Format{}, err } switch contentType { case "application/ogg", "audio/ogg": - return vorbis.Decode(f.File) + return vorbis.Decode(f) case "audio/mpeg": - return mp3.Decode(f.File) + return mp3.Decode(f) case "audio/wave", "audio/x-wav": - return wav.Decode(f.File) + return wav.Decode(f) case "audio/x-flac": - return flac.Decode(f.File) + return flac.Decode(f) } return nil, beep.Format{}, fmt.Errorf("%w: %s", ErrUnsupportedFileType, contentType) } diff --git a/internal/stream/streamer.go b/internal/stream/streamer.go index 749fd410..f34f88c5 100644 --- a/internal/stream/streamer.go +++ b/internal/stream/streamer.go @@ -22,9 +22,7 @@ func (s Streamer) Close() error { } func NewStreamer(rawFile fs.File, entry preset.Track) (streamer Streamer, err error) { - f := File{File: rawFile} - - closer, format, err := f.Decode() + closer, format, err := Decode(rawFile) if err != nil { return streamer, err }