Skip to content

Commit

Permalink
feat(subsonic): support timeOffset in stream.view
Browse files Browse the repository at this point in the history
  • Loading branch information
sentriz committed Sep 28, 2023
1 parent 2caee44 commit 3365591
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/ctrlsubsonic/handlers_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ func (c *Controller) ServePing(_ *http.Request) *spec.Response {

func (c *Controller) ServeGetOpenSubsonicExtensions(_ *http.Request) *spec.Response {
sub := spec.NewResponse()
sub.OpenSubsonicExtensions = spec.OpenSubsonicExtensions{}
sub.OpenSubsonicExtensions = spec.OpenSubsonicExtensions{
"transcodeOffset": {1},
}
return sub
}

Expand Down
4 changes: 4 additions & 0 deletions server/ctrlsubsonic/handlers_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.R

maxBitRate, _ := params.GetInt("maxBitRate")
format, _ := params.Get("format")
timeOffset, _ := params.GetInt("timeOffset")

if format == "raw" || maxBitRate >= audioFile.AudioBitrate() {
http.ServeFile(w, r, file.AbsPath())
Expand All @@ -240,6 +241,9 @@ func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.R
if maxBitRate > 0 && int(profile.BitRate()) > maxBitRate {
profile = transcode.WithBitrate(profile, transcode.BitRate(maxBitRate))
}
if timeOffset > 0 {
profile = transcode.WithSeek(profile, time.Second*time.Duration(timeOffset))
}

log.Printf("trancoding to %q with max bitrate %dk", profile.MIME(), profile.BitRate())

Expand Down

0 comments on commit 3365591

Please sign in to comment.