mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 09:53:33 +00:00
Preparation to music streaming
This commit is contained in:
parent
f837bb14e2
commit
a28ad27288
23 changed files with 615 additions and 279 deletions
|
|
@ -6,6 +6,12 @@ import android.content.SharedPreferences;
|
|||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.cappielloantonio.play.helper.ThemeHelper;
|
||||
import com.cappielloantonio.play.model.DirectPlayCodec;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class PreferenceUtil {
|
||||
public static final String SERVER = "server";
|
||||
|
|
@ -19,6 +25,10 @@ public class PreferenceUtil {
|
|||
public static final String HOST_URL = "host";
|
||||
public static final String IMAGE_CACHE_SIZE = "image_cache_size";
|
||||
|
||||
public static final String TRANSCODE_CODEC = "transcode_codec";
|
||||
public static final String DIRECT_PLAY_CODECS = "direct_play_codecs";
|
||||
public static final String MAXIMUM_BITRATE = "maximum_bitrate";
|
||||
|
||||
private static PreferenceUtil sInstance;
|
||||
|
||||
private final SharedPreferences mPreferences;
|
||||
|
|
@ -104,4 +114,46 @@ public class PreferenceUtil {
|
|||
public final int getImageCacheSize() {
|
||||
return Integer.parseInt(mPreferences.getString(IMAGE_CACHE_SIZE, "400000000"));
|
||||
}
|
||||
|
||||
public final String getTranscodeCodec() {
|
||||
return mPreferences.getString(TRANSCODE_CODEC, "aac");
|
||||
}
|
||||
|
||||
public final String getMaximumBitrate() {
|
||||
return mPreferences.getString(MAXIMUM_BITRATE, "10000000");
|
||||
}
|
||||
|
||||
public List<DirectPlayCodec> getDirectPlayCodecs() {
|
||||
DirectPlayCodec.Codec[] codecs = DirectPlayCodec.Codec.values();
|
||||
|
||||
Set<String> selectedCodecNames = new HashSet<>();
|
||||
for (DirectPlayCodec.Codec codec : codecs) {
|
||||
// this will be the default value
|
||||
selectedCodecNames.add(codec.name());
|
||||
}
|
||||
|
||||
selectedCodecNames = mPreferences.getStringSet(DIRECT_PLAY_CODECS, selectedCodecNames);
|
||||
|
||||
ArrayList<DirectPlayCodec> directPlayCodecs = new ArrayList<>();
|
||||
for (DirectPlayCodec.Codec codec : codecs) {
|
||||
String name = codec.name();
|
||||
boolean selected = selectedCodecNames.contains(name);
|
||||
directPlayCodecs.add(new DirectPlayCodec(codec, selected));
|
||||
}
|
||||
|
||||
return directPlayCodecs;
|
||||
}
|
||||
|
||||
public void setDirectPlayCodecs(List<DirectPlayCodec> directPlayCodecs) {
|
||||
Set<String> codecNames = new HashSet<>();
|
||||
for (DirectPlayCodec directPlayCodec : directPlayCodecs) {
|
||||
if (directPlayCodec.selected) {
|
||||
codecNames.add(directPlayCodec.codec.toString());
|
||||
}
|
||||
}
|
||||
|
||||
final SharedPreferences.Editor editor = mPreferences.edit();
|
||||
editor.putStringSet(DIRECT_PLAY_CODECS, codecNames);
|
||||
editor.apply();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue