add preferences for maximum bitrate and transcoding codec

This commit is contained in:
dkanada 2020-05-23 10:20:29 +09:00
commit f1c84d7ae7
7 changed files with 66 additions and 5 deletions

View file

@ -21,12 +21,10 @@ Since this was a small project intended mainly for myself, there are some things
* Playlists and favorites will not update automatically when changed
* Sorting also requires a reload to take effect
* Batch actions are not yet functional
* Some reports of audio playback ending prematurely
## Future Plans
I don't currently have plans to add any large features. If I ever find the time, these are some of the items I would potentially include.
* Offline downloads
* Transcoding
* Support for other media types

View file

@ -38,14 +38,14 @@ public class MusicUtil {
builder.append("?UserId=" + apiClient.getCurrentUserId());
builder.append("&DeviceId=" + apiClient.getDeviceId());
// web max is 12444445 and 320kbps is 320000
builder.append("&MaxStreamingBitrate=10000000");
// web client maximum is 12444445 and 320kbps is 320000
builder.append("&MaxStreamingBitrate=" + PreferenceUtil.getInstance(App.getInstance()).getMaximumBitrate());
builder.append("&Container=flac");
builder.append("&TranscodingContainer=ts");
builder.append("&TranscodingProtocol=hls");
// preferred codec when transcoding
builder.append("&AudioCodec=aac");
builder.append("&AudioCodec=" + PreferenceUtil.getInstance(App.getInstance()).getTranscodeCodec());
builder.append("&api_key=" + apiClient.getAccessToken());
Log.i(MusicUtil.class.getName(), "playing audio: " + builder);

View file

@ -52,6 +52,8 @@ public final class PreferenceUtil {
public static final String GENERAL_THEME = "general_theme";
public static final String COLORED_SHORTCUTS = "colored_shortcuts";
public static final String TRANSCODE_CODEC = "transcode_codec";
public static final String MAXIMUM_BITRATE = "maximum_bitrate";
public static final String AUDIO_DUCKING = "audio_ducking";
public static final String REMEMBER_SHUFFLE = "remember_shuffle";
@ -163,6 +165,14 @@ public final class PreferenceUtil {
editor.apply();
}
public final String getTranscodeCodec() {
return mPreferences.getString(TRANSCODE_CODEC, "aac");
}
public final String getMaximumBitrate() {
return mPreferences.getString(MAXIMUM_BITRATE, "320000");
}
public final boolean getAudioDucking() {
return mPreferences.getBoolean(AUDIO_DUCKING, true);
}

View file

@ -12,4 +12,27 @@
<item>black</item>
</string-array>
<string-array name="pref_transcode_codec_titles">
<item>@string/codec_aac</item>
<item>@string/codec_mp3</item>
</string-array>
<string-array name="pref_transcode_codec_values">
<item>aac</item>
<item>mp3</item>
</string-array>
<string-array name="pref_maximum_bitrate_titles">
<item>@string/bitrate_unlimited</item>
<item>@string/bitrate_320kbps</item>
<item>@string/bitrate_256kbps</item>
<item>@string/bitrate_128kbps</item>
</string-array>
<string-array name="pref_maximum_bitrate_values">
<item>10000000</item>
<item>320000</item>
<item>256000</item>
<item>128000</item>
</string-array>
</resources>

View file

@ -18,4 +18,12 @@
<string name="random" translatable="false">\?</string>
<string name="bitrate_unlimited" translatable="false">Unlimited</string>
<string name="bitrate_320kbps" translatable="false">320Kbps</string>
<string name="bitrate_256kbps" translatable="false">256Kbps</string>
<string name="bitrate_128kbps" translatable="false">128Kbps</string>
<string name="codec_aac" translatable="false">AAC</string>
<string name="codec_mp3" translatable="false">MP3</string>
</resources>

View file

@ -76,6 +76,8 @@
<string name="pref_title_app_shortcuts">Colored app shortcuts</string>
<string name="pref_title_album_art_on_lockscreen">Show album cover</string>
<string name="pref_title_blurred_album_art">Blur album cover</string>
<string name="pref_title_transcode_codec">Transcode codec</string>
<string name="pref_title_maximum_bitrate">Maximum bitrate</string>
<string name="pref_title_classic_notification">Classic design</string>
<string name="pref_title_colored_notification">Colored notification</string>
<string name="pref_title_gapless_playback">Gapless playback</string>

View file

@ -4,6 +4,26 @@
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory android:title="@string/pref_header_audio">
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEListPreference
app:iconSpaceReserved="false"
android:defaultValue="aac"
android:entries="@array/pref_transcode_codec_titles"
android:entryValues="@array/pref_transcode_codec_values"
android:key="transcode_codec"
android:negativeButtonText="@null"
android:positiveButtonText="@null"
android:title="@string/pref_title_transcode_codec" />
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEListPreference
app:iconSpaceReserved="false"
android:defaultValue="320000"
android:entries="@array/pref_maximum_bitrate_titles"
android:entryValues="@array/pref_maximum_bitrate_values"
android:key="maximum_bitrate"
android:negativeButtonText="@null"
android:positiveButtonText="@null"
android:title="@string/pref_title_maximum_bitrate" />
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATESwitchPreference
app:iconSpaceReserved="false"
android:defaultValue="true"