From 7d4de3f6a6d1aa9d811c9ecfc4a15459ea971adc Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Mon, 9 Oct 2023 01:15:05 +0400 Subject: [PATCH] Add 5 seconds to time.Now() to more accurately represent the time when a song actually starts to play. --- internal/http/dj_handlers.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/http/dj_handlers.go b/internal/http/dj_handlers.go index 42976f3..d1a45a4 100644 --- a/internal/http/dj_handlers.go +++ b/internal/http/dj_handlers.go @@ -83,7 +83,10 @@ func (dj *DJHandlers) PlaylistNext(w http.ResponseWriter, _ *http.Request) { Title: oggf.GetTag("title"), Duration: oggf.GetDuration(), MaxListeners: dj.listeners.Current(), - StartAt: time.Now()} + // Here 5 seconds are being added because it is approximately the + // time between the creation of this Song object and when ezstream + // actually starts to play it. + StartAt: time.Now().Add(5 * time.Second)} if strings.HasSuffix(nxt, "/fallback.ogg") { song.Artist = "Nothing to play. Playing a fallback: " + song.Artist