In handlers made use of oggtag.ReadFile() func. Also updated func names.
This commit is contained in:
parent
c054c3b32e
commit
7cc228968d
@ -7,7 +7,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -58,17 +57,15 @@ func (dj *DJHandlers) PlaylistNext(w http.ResponseWriter, _ *http.Request) {
|
|||||||
log.Println("the end of a playlist has been reached")
|
log.Println("the end of a playlist has been reached")
|
||||||
} else {
|
} else {
|
||||||
go func() {
|
go func() {
|
||||||
f, err := os.Open(nxt)
|
bs, be, err := oggtag.ReadFile(nxt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("cannot open file \"", nxt, "\" to read tags")
|
log.Println("cannot read an OGG file", nxt, ":", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := make([]byte, 4096)
|
|
||||||
f.Read(buf)
|
|
||||||
|
|
||||||
song := radio.Song_{
|
song := radio.Song_{
|
||||||
Artist: oggtag.OggGetTag(buf, "artist"),
|
Artist: oggtag.GetTag(bs, "artist"),
|
||||||
Title: oggtag.OggGetTag(buf, "title"),
|
Title: oggtag.GetTag(bs, "title"),
|
||||||
|
Duration: oggtag.GetDuration(bs, be),
|
||||||
MaxListeners: dj.listeners.Current(),
|
MaxListeners: dj.listeners.Current(),
|
||||||
StartAt: time.Now()}
|
StartAt: time.Now()}
|
||||||
// radio.CheckAndUpdateMostListenedSong(song, currentSong)
|
// radio.CheckAndUpdateMostListenedSong(song, currentSong)
|
||||||
|
Loading…
Reference in New Issue
Block a user