From c22fb3d482dd28e28cb7facc90fd0c1ea8ebea1f Mon Sep 17 00:00:00 2001 From: Serge Tkatchouk Date: Thu, 13 Feb 2020 23:10:49 +0800 Subject: [PATCH] Switch "/stream" controller to new "encode or stream cache" function --- server/ctrlsubsonic/handlers_raw.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/server/ctrlsubsonic/handlers_raw.go b/server/ctrlsubsonic/handlers_raw.go index e0b25fd..9020ff1 100644 --- a/server/ctrlsubsonic/handlers_raw.go +++ b/server/ctrlsubsonic/handlers_raw.go @@ -69,10 +69,9 @@ func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.R track.Album.RightPath, track.Filename, ) - if mime, ok := mime.Types[track.Ext()]; ok { - w.Header().Set("Content-Type", mime) - } - http.ServeFile(w, r, absPath) + StreamTrack(w, r, absPath, client, c.CachePath) + + // // after we've served the file, mark the album as played user := r.Context().Value(CtxUser).(*db.User) play := db.Play{ @@ -109,6 +108,9 @@ func (c *Controller) ServeDownload(w http.ResponseWriter, r *http.Request) *spec track.Album.RightPath, track.Filename, ) + if mime, ok := mime.Types[track.Ext()]; ok { + w.Header().Set("Content-Type", mime) + } http.ServeFile(w, r, absPath) //