Can listen to gong on the page

This commit is contained in:
nemunaire 2022-10-15 13:47:57 +02:00
commit 7db7489b4c
3 changed files with 52 additions and 0 deletions

View file

@ -66,6 +66,33 @@ func LoadGongs(cfg *config.Config) (gongs []*Gong, err error) {
return
}
func (g *Gong) Open() (*os.File, error) {
return os.Open(g.Path)
}
func (g *Gong) Size() (int64, error) {
if st, err := os.Stat(g.Path); err != nil {
return 0, err
} else {
return st.Size(), err
}
}
func (g *Gong) ContentType() string {
switch filepath.Ext(g.Path) {
case ".flac":
return "audio/flac"
case ".mp3":
return "audio/mpeg"
case ".ogg":
return "audio/ogg"
case ".wav":
return "audio/vnd.wav"
}
return "application/octet-stream"
}
func (g *Gong) Rename(newName string) error {
newPath := filepath.Join(filepath.Dir(g.Path), newName+filepath.Ext(g.Path))