🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Hack to make streaming work, but with wrong content-length
Deluan42f3279aaf70
diff --git a/api/stream.go b/api/stream.goindex e7bbafd38..854fcb066 100644--- a/api/stream.go+++ b/api/stream.go@@ -1,8 +1,6 @@package apiimport (- "strconv"-"github.com/astaxie/beego""github.com/deluan/gosonic/api/responses""github.com/deluan/gosonic/domain"@@ -46,16 +44,22 @@ func (c *StreamController) Stream() {beego.Debug("Streaming file", c.id, ":", c.mf.Path)beego.Debug("Bitrate", c.mf.BitRate, "MaxBitRate", maxBitRate)- contentLength := c.mf.Size- if maxBitRate > 0 {- contentLength = strconv.Itoa((c.mf.Duration + 1) * maxBitRate * 1000 / 8)- }- c.Ctx.Output.Header("Content-Length", contentLength)+ // TODO Send proper estimated content-length+ //contentLength := c.mf.Size+ //if maxBitRate > 0 {+ // contentLength = strconv.Itoa((c.mf.Duration + 1) * maxBitRate * 1000 / 8)+ //}+ c.Ctx.Output.Header("Content-Length", c.mf.Size)c.Ctx.Output.Header("Content-Type", "audio/mpeg")c.Ctx.Output.Header("Expires", "0")c.Ctx.Output.Header("Cache-Control", "must-revalidate")c.Ctx.Output.Header("Pragma", "public")+ if c.Ctx.Request.Method == "HEAD" {+ beego.Debug("Just a HEAD. Not streaming", c.mf.Path)+ return+ }+err := engine.Stream(c.mf.Path, c.mf.BitRate, maxBitRate, c.Ctx.ResponseWriter)if err != nil {beego.Error("Error streaming file", c.id, ":", err)diff --git a/conf/app.conf b/conf/app.confindex c4f354736..c8cf772fa 100644--- a/conf/app.conf+++ b/conf/app.conf@@ -20,8 +20,8 @@ plsIgnoreFolders = trueplsIgnoredPatterns = ^iCloud;^CDs para;^Skipped;Christian[dev]-disableValidation = false-enableDownsampling = false+disableValidation = true+enableDownsampling = trueenableAdmin = true[test]