feat: Implement duration and seeking for transcodes (#358)

Co-authored-by: eddyizm <eddyizm@gmail.com>
This commit is contained in:
drakeerv 2026-01-24 11:28:47 -05:00 committed by GitHub
parent e5b7756f96
commit bde34d3df0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 340 additions and 3 deletions

View file

@ -31,7 +31,7 @@ public class MusicUtil {
private static final Pattern BITRATE_PATTERN = Pattern.compile("&maxBitRate=\\d+");
private static final Pattern FORMAT_PATTERN = Pattern.compile("&format=\\w+");
public static Uri getStreamUri(String id) {
public static Uri getStreamUri(String id, int timeOffset) {
Map<String, String> params = App.getSubsonicClientInstance(false).getParams();
StringBuilder uri = new StringBuilder();
@ -58,6 +58,8 @@ public class MusicUtil {
uri.append("&format=").append(getTranscodingFormatPreference());
if (Preferences.askForEstimateContentLength())
uri.append("&estimateContentLength=true");
if (timeOffset > 0)
uri.append("&timeOffset=").append(timeOffset);
uri.append("&id=").append(id);
@ -66,6 +68,10 @@ public class MusicUtil {
return Uri.parse(uri.toString());
}
public static Uri getStreamUri(String id) {
return getStreamUri(id, 0);
}
public static Uri updateStreamUri(Uri uri) {
String s = uri.toString();
Matcher m1 = BITRATE_PATTERN.matcher(s);