mirror of
https://github.com/CappielloAntonio/tempo.git
synced 2026-02-01 07:03:35 +00:00
Add audio transcode format option and bitrate
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.cappielloantonio.play.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.R;
|
||||
@@ -17,18 +19,34 @@ import java.util.regex.Pattern;
|
||||
public class MusicUtil {
|
||||
private static final String TAG = "MusicUtil";
|
||||
|
||||
public static String getSongFileUri(Song song) {
|
||||
String url = App.getSubsonicClientInstance(App.getInstance(), false).getUrl();
|
||||
|
||||
public static String getSongStreamUri(Context context, Song song) {
|
||||
Map<String, String> params = App.getSubsonicClientInstance(App.getInstance(), false).getParams();
|
||||
|
||||
return url + "stream" +
|
||||
return App.getSubsonicClientInstance(App.getInstance(), false).getUrl() +
|
||||
"stream" +
|
||||
"?u=" + params.get("u") +
|
||||
"&s=" + params.get("s") +
|
||||
"&t=" + params.get("t") +
|
||||
"&v=" + params.get("v") +
|
||||
"&c=" + params.get("c") +
|
||||
"&id=" + song.getId() +
|
||||
"&maxBitRate=" + PreferenceUtil.getInstance(context).getMaxBitrateWifi() +
|
||||
"&format=" + PreferenceUtil.getInstance(context).getAudioTranscodeFormat();
|
||||
}
|
||||
|
||||
public static MediaItem getSongDownloadItem(Song song) {
|
||||
Map<String, String> params = App.getSubsonicClientInstance(App.getInstance(), false).getParams();
|
||||
|
||||
String uri = App.getSubsonicClientInstance(App.getInstance(), false).getUrl() +
|
||||
"stream" +
|
||||
"?u=" + params.get("u") +
|
||||
"&s=" + params.get("s") +
|
||||
"&t=" + params.get("t") +
|
||||
"&v=" + params.get("v") +
|
||||
"&c=" + params.get("c") +
|
||||
"&id=" + song.getId();
|
||||
|
||||
return MediaItem.fromUri(uri);
|
||||
}
|
||||
|
||||
public static String getReadableDurationString(long duration, boolean millis) {
|
||||
@@ -110,9 +128,4 @@ public class MusicUtil {
|
||||
return R.drawable.default_album_art;
|
||||
}
|
||||
}
|
||||
|
||||
public static MediaItem getMediaItemFromSong(Song song) {
|
||||
String uri = MusicUtil.getSongFileUri(song);
|
||||
return MediaItem.fromUri(uri);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@ public class PreferenceUtil {
|
||||
public static final String IMAGE_CACHE_SIZE = "image_cache_size";
|
||||
public static final String IMAGE_SIZE = "image_size";
|
||||
public static final String MEDIA_CACHE_SIZE = "media_cache_size";
|
||||
public static final String MAX_BITRATE_WIFI = "max_bitrate_wifi";
|
||||
public static final String MAX_BITRATE_MOBILE = "max_bitrate_mobile";
|
||||
public static final String AUDIO_TRANSCODE_FORMAT = "audio_transcode_format";
|
||||
public static final String WIFI_ONLY = "wifi_only";
|
||||
|
||||
private static PreferenceUtil sInstance;
|
||||
private final SharedPreferences mPreferences;
|
||||
@@ -42,7 +46,7 @@ public class PreferenceUtil {
|
||||
}
|
||||
|
||||
public String getServer() {
|
||||
return mPreferences.getString(SERVER, "https://jellyfin.org");
|
||||
return mPreferences.getString(SERVER, "");
|
||||
}
|
||||
|
||||
public void setServer(String server) {
|
||||
@@ -132,4 +136,20 @@ public class PreferenceUtil {
|
||||
public final int getImageSize() {
|
||||
return Integer.parseInt(mPreferences.getString(IMAGE_SIZE, "-1"));
|
||||
}
|
||||
|
||||
public final String getMaxBitrateWifi() {
|
||||
return mPreferences.getString(MAX_BITRATE_WIFI, "0");
|
||||
}
|
||||
|
||||
public final String getMaxBitrateMobile() {
|
||||
return mPreferences.getString(MAX_BITRATE_MOBILE, "0");
|
||||
}
|
||||
|
||||
public final String getAudioTranscodeFormat() {
|
||||
return mPreferences.getString(AUDIO_TRANSCODE_FORMAT, "raw");
|
||||
}
|
||||
|
||||
public final boolean isWifiOnly() {
|
||||
return mPreferences.getBoolean(WIFI_ONLY, false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user