From e762c91ff373b62136cb268225b473a99bd555c4 Mon Sep 17 00:00:00 2001 From: antonio Date: Sun, 17 Sep 2023 19:12:45 +0200 Subject: [PATCH] feat: added setting to request estimated duration of transcoded file --- .../com/cappielloantonio/tempo/util/MusicUtil.java | 3 +-- .../com/cappielloantonio/tempo/util/Preferences.kt | 6 ++++++ app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/xml/global_preferences.xml | 10 ++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/cappielloantonio/tempo/util/MusicUtil.java b/app/src/main/java/com/cappielloantonio/tempo/util/MusicUtil.java index d27f49f7..9fdb1250 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/util/MusicUtil.java +++ b/app/src/main/java/com/cappielloantonio/tempo/util/MusicUtil.java @@ -50,12 +50,11 @@ public class MusicUtil { uri.append("&maxBitRate=").append(getBitratePreference()); if (!Preferences.isServerPrioritized()) uri.append("&format=").append(getTranscodingFormatPreference()); - if (false) + if (Preferences.askForEstimateContentLength()) uri.append("&estimateContentLength=true"); uri.append("&id=").append(id); - Log.d(TAG, "getStreamUri: " + uri); return Uri.parse(uri.toString()); diff --git a/app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt b/app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt index 05bf2643..985ccc32 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt +++ b/app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt @@ -40,6 +40,7 @@ object Preferences { private const val MAX_BITRATE_DOWNLOAD = "max_bitrate_download" private const val AUDIO_TRANSCODE_FORMAT_DOWNLOAD = "audio_transcode_format_download" private const val SHARE = "share" + private const val ESTIMATE_CONTENT_LENGTH = "estimate_content_length" @JvmStatic fun getServer(): String? { @@ -319,4 +320,9 @@ object Preferences { fun isSharingEnabled(): Boolean { return App.getInstance().preferences.getBoolean(SHARE, false) } + + @JvmStatic + fun askForEstimateContentLength(): Boolean { + return App.getInstance().preferences.getBoolean(ESTIMATE_CONTENT_LENGTH, false) + } } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0ab2c856..354ff843 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -190,6 +190,8 @@ If enabled, Tempo will download transcoded tracks. Download transcoded tracks Transcode format + If enabled, the server will be asked for the estimated duration of the track. + Estimate content length If enabled, Tempo will not force stream the track with the transcode settings below. Prioritize server transcode settings Priority on transcoding of track given to server @@ -234,6 +236,7 @@ Allows the user to share music via a link. The functionality must be supported and enabled server-side and is limited to individual tracks, albums and playlists. Returns the state of the play queue for this user. This includes the tracks in the play queue, the currently playing track, and the position within this track. The server must support this feature. Priority given to the transcoding mode. If set to \"Direct play\" the bitrate of the file will not be changed. + When the file is transcoded on the fly, the client usually does not show the track length. It is possible to request the servers that support the functionality to estimate the duration of the track being played, but the response times may take longer. Download transcoded media. If enabled, the download endpoint will not be used, but the following settings. \n\n If \"Transcode format\" is set to \"Direct play\" the bitrate of the file will not be changed. If enabled, starred tracks will be downloaded for offline use. Sync starred tracks for offline use diff --git a/app/src/main/res/xml/global_preferences.xml b/app/src/main/res/xml/global_preferences.xml index 2b056dc2..d1b0cb0f 100644 --- a/app/src/main/res/xml/global_preferences.xml +++ b/app/src/main/res/xml/global_preferences.xml @@ -158,6 +158,16 @@ app:key="max_bitrate_mobile" app:title="@string/settings_max_bitrate_mobile" app:useSimpleSummaryProvider="true" /> + + + +