feat(subsonic): support timeOffset in stream.view (#384)
as per https://github.com/opensubsonic/open-subsonic-api/pull/54 https://github.com/opensubsonic/open-subsonic-api/discussions/21 dont cache partial transcodes add a transcode seek test
This commit is contained in:
@@ -38,7 +38,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{
|
||||
{Name: "transcodeOffset", Versions: []int{1}},
|
||||
}
|
||||
return sub
|
||||
}
|
||||
|
||||
|
||||
@@ -186,6 +186,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())
|
||||
@@ -208,6 +209,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())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user