mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Add audio transcode format option and bitrate
This commit is contained in:
parent
10df98306c
commit
bb9b2d95b5
8 changed files with 175 additions and 36 deletions
|
|
@ -63,14 +63,14 @@ public class DownloadTracker {
|
|||
}
|
||||
|
||||
public boolean isDownloaded(Song song) {
|
||||
MediaItem mediaItem = MusicUtil.getMediaItemFromSong(song);
|
||||
MediaItem mediaItem = MusicUtil.getSongDownloadItem(song);
|
||||
@Nullable Download download = downloads.get(checkNotNull(mediaItem.playbackProperties).uri);
|
||||
return download != null && download.state != Download.STATE_FAILED;
|
||||
}
|
||||
|
||||
public boolean isDownloaded(List<Song> songs) {
|
||||
for (Song song : songs) {
|
||||
MediaItem mediaItem = MusicUtil.getMediaItemFromSong(song);
|
||||
MediaItem mediaItem = MusicUtil.getSongDownloadItem(song);
|
||||
@Nullable Download download = downloads.get(checkNotNull(mediaItem.playbackProperties).uri);
|
||||
|
||||
if (download != null && download.state != Download.STATE_FAILED) {
|
||||
|
|
@ -95,7 +95,7 @@ public class DownloadTracker {
|
|||
continue;
|
||||
}
|
||||
|
||||
MediaItem mediaItem = MusicUtil.getMediaItemFromSong(song);
|
||||
MediaItem mediaItem = MusicUtil.getSongDownloadItem(song);
|
||||
DownloadService.sendAddDownload(context, DownloaderService.class, getDownloadRequest(song.getId(), checkNotNull(mediaItem.playbackProperties).uri), false);
|
||||
downloadRepository.insert(MappingUtil.mapToDownload(song, playlistId, playlistName));
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ public class DownloadTracker {
|
|||
DownloadRepository downloadRepository = new DownloadRepository(App.getInstance());
|
||||
|
||||
for (Song song : songs) {
|
||||
MediaItem mediaItem = MusicUtil.getMediaItemFromSong(song);
|
||||
MediaItem mediaItem = MusicUtil.getSongDownloadItem(song);
|
||||
|
||||
@Nullable Download download = downloads.get(checkNotNull(mediaItem.playbackProperties).uri);
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ public class MultiPlayer implements Playback {
|
|||
|
||||
@Override
|
||||
public void setDataSource(Song song) {
|
||||
String uri = MusicUtil.getSongFileUri(song);
|
||||
String uri = MusicUtil.getSongStreamUri(context, song);
|
||||
MediaItem mediaItem = exoPlayer.getCurrentMediaItem();
|
||||
|
||||
if (mediaItem != null && mediaItem.playbackProperties != null && mediaItem.playbackProperties.uri.toString().equals(uri)) {
|
||||
|
|
@ -138,7 +138,7 @@ public class MultiPlayer implements Playback {
|
|||
}
|
||||
|
||||
exoPlayer.clearMediaItems();
|
||||
appendDataSource(MusicUtil.getSongFileUri(song));
|
||||
appendDataSource(MusicUtil.getSongStreamUri(context, song));
|
||||
exoPlayer.seekTo(0, 0);
|
||||
}
|
||||
|
||||
|
|
@ -149,7 +149,7 @@ public class MultiPlayer implements Playback {
|
|||
exoPlayer.removeMediaItem(1);
|
||||
}
|
||||
|
||||
appendDataSource(MusicUtil.getSongFileUri(song));
|
||||
appendDataSource(MusicUtil.getSongStreamUri(context, song));
|
||||
}
|
||||
|
||||
private void appendDataSource(String path) {
|
||||
|
|
|
|||
|
|
@ -81,14 +81,16 @@ public class ServerSignupDialog extends DialogFragment {
|
|||
}
|
||||
|
||||
private void setServerInfo() {
|
||||
loginViewModel.setServerToEdit(requireArguments().getParcelable("server_object"));
|
||||
if (getArguments() != null) {
|
||||
loginViewModel.setServerToEdit(requireArguments().getParcelable("server_object"));
|
||||
|
||||
if (loginViewModel.getServerToEdit() != null) {
|
||||
bind.serverNameTextView.setText(loginViewModel.getServerToEdit().getServerName());
|
||||
bind.usernameTextView.setText(loginViewModel.getServerToEdit().getUsername());
|
||||
bind.passwordTextView.setText("");
|
||||
bind.serverTextView.setText(loginViewModel.getServerToEdit().getAddress());
|
||||
bind.directAccessCheckbox.setChecked(false);
|
||||
if (loginViewModel.getServerToEdit() != null) {
|
||||
bind.serverNameTextView.setText(loginViewModel.getServerToEdit().getServerName());
|
||||
bind.usernameTextView.setText(loginViewModel.getServerToEdit().getUsername());
|
||||
bind.passwordTextView.setText("");
|
||||
bind.serverTextView.setText(loginViewModel.getServerToEdit().getAddress());
|
||||
bind.directAccessCheckbox.setChecked(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,10 @@
|
|||
<resources>
|
||||
<!-- Reply Preference -->
|
||||
|
||||
<string-array name="themeListArray">
|
||||
<string-array name="theme_list_titles">
|
||||
<item>Light</item>
|
||||
<item>Dark</item>
|
||||
<item>System default</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="themeEntryArray">
|
||||
<string-array name="theme_list_values">
|
||||
<item>light</item>
|
||||
<item>dark</item>
|
||||
<item>default</item>
|
||||
|
|
@ -20,7 +17,6 @@
|
|||
<item>400MB</item>
|
||||
<item>200MB</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_cache_size_values">
|
||||
<item>4000000000</item>
|
||||
<item>2000000000</item>
|
||||
|
|
@ -36,7 +32,6 @@
|
|||
<item>400MB</item>
|
||||
<item>200MB</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_media_cache_size_values">
|
||||
<item>4000000000</item>
|
||||
<item>2000000000</item>
|
||||
|
|
@ -50,10 +45,82 @@
|
|||
<item>Medium</item>
|
||||
<item>Low</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_image_size_values">
|
||||
<item>-1</item>
|
||||
<item>500</item>
|
||||
<item>300</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="max_bitrate_wifi_list_titles">
|
||||
<item>Original</item>
|
||||
<item>32</item>
|
||||
<item>48</item>
|
||||
<item>64</item>
|
||||
<item>80</item>
|
||||
<item>96</item>
|
||||
<item>112</item>
|
||||
<item>128</item>
|
||||
<item>160</item>
|
||||
<item>192</item>
|
||||
<item>256</item>
|
||||
<item>320</item>
|
||||
</string-array>
|
||||
<string-array name="max_bitrate_wifi_list_values">
|
||||
<item>0</item>
|
||||
<item>32</item>
|
||||
<item>48</item>
|
||||
<item>64</item>
|
||||
<item>80</item>
|
||||
<item>96</item>
|
||||
<item>112</item>
|
||||
<item>128</item>
|
||||
<item>160</item>
|
||||
<item>192</item>
|
||||
<item>256</item>
|
||||
<item>320</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="max_bitrate_mobile_list_titles">
|
||||
<item>Original</item>
|
||||
<item>32</item>
|
||||
<item>48</item>
|
||||
<item>64</item>
|
||||
<item>80</item>
|
||||
<item>96</item>
|
||||
<item>112</item>
|
||||
<item>128</item>
|
||||
<item>160</item>
|
||||
<item>192</item>
|
||||
<item>256</item>
|
||||
<item>320</item>
|
||||
</string-array>
|
||||
<string-array name="max_bitrate_mobile_list_values">
|
||||
<item>0</item>
|
||||
<item>32</item>
|
||||
<item>48</item>
|
||||
<item>64</item>
|
||||
<item>80</item>
|
||||
<item>96</item>
|
||||
<item>112</item>
|
||||
<item>128</item>
|
||||
<item>160</item>
|
||||
<item>192</item>
|
||||
<item>256</item>
|
||||
<item>320</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="audio_transcode_format_list_titles">
|
||||
<item>Original</item>
|
||||
<item>Opus</item>
|
||||
<item>AAC</item>
|
||||
<item>Mp3</item>
|
||||
<item>Flac</item>
|
||||
</string-array>
|
||||
<string-array name="audio_transcode_format_list_values">
|
||||
<item>raw</item>
|
||||
<item>opus</item>
|
||||
<item>aac</item>
|
||||
<item>mp3</item>
|
||||
<item>flac</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
|
@ -141,16 +141,21 @@
|
|||
<string name="server_signup_dialog_title">Add server</string>
|
||||
<string name="settings_about_summary">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</string>
|
||||
<string name="settings_about_title">About</string>
|
||||
<string name="settings_audio_transcode_format">Transcode format</string>
|
||||
<string name="settings_covers_cache">Covers cache</string>
|
||||
<string name="settings_github_link">https://github.com/CappielloAntonio/play-for-subsonic</string>
|
||||
<string name="settings_github_summary">Follow the development</string>
|
||||
<string name="settings_github_title">Github</string>
|
||||
<string name="settings_image_size">Cover size</string>
|
||||
<string name="settings_max_bitrate_wifi">Bitrate in WiFi</string>
|
||||
<string name="settings_max_bitrate_mobile">Bitrate in mobile</string>
|
||||
<string name="settings_media_cache">Media cache</string>
|
||||
<string name="settings_theme">Choose theme</string>
|
||||
<string name="settings_title_general">General</string>
|
||||
<string name="settings_version_summary">1.0</string>
|
||||
<string name="settings_version_title">Version</string>
|
||||
<string name="settings_wifi_only_title">WiFi only</string>
|
||||
<string name="settings_wifi_only_summary">Summary WiFi only</string>
|
||||
<string name="song_bottom_sheet_add_to_playlist">Add to playlist</string>
|
||||
<string name="song_bottom_sheet_add_to_queue">Add to queue</string>
|
||||
<string name="song_bottom_sheet_download">Download</string>
|
||||
|
|
|
|||
|
|
@ -31,12 +31,45 @@
|
|||
<ListPreference
|
||||
app:defaultValue="default"
|
||||
app:dialogTitle="@string/settings_theme"
|
||||
app:entries="@array/themeListArray"
|
||||
app:entryValues="@array/themeEntryArray"
|
||||
app:key="themePref"
|
||||
app:entries="@array/theme_list_titles"
|
||||
app:entryValues="@array/theme_list_values"
|
||||
app:key="theme"
|
||||
app:title="@string/settings_theme"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<ListPreference
|
||||
app:defaultValue="0"
|
||||
app:dialogTitle="@string/settings_max_bitrate_wifi"
|
||||
app:entries="@array/max_bitrate_wifi_list_titles"
|
||||
app:entryValues="@array/max_bitrate_wifi_list_values"
|
||||
app:key="max_bitrate_wifi"
|
||||
app:title="@string/settings_max_bitrate_wifi"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<ListPreference
|
||||
app:defaultValue="0"
|
||||
app:dialogTitle="@string/settings_max_bitrate_mobile"
|
||||
app:entries="@array/max_bitrate_mobile_list_titles"
|
||||
app:entryValues="@array/max_bitrate_mobile_list_values"
|
||||
app:key="max_bitrate_mobile"
|
||||
app:title="@string/settings_max_bitrate_mobile"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<ListPreference
|
||||
app:defaultValue="raw"
|
||||
app:dialogTitle="@string/settings_audio_transcode_format"
|
||||
app:entries="@array/audio_transcode_format_list_titles"
|
||||
app:entryValues="@array/audio_transcode_format_list_values"
|
||||
app:key="audio_transcode_format"
|
||||
app:title="@string/settings_audio_transcode_format"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:title="@string/settings_wifi_only_title"
|
||||
android:defaultValue="false"
|
||||
android:summary="@string/settings_wifi_only_summary"
|
||||
android:key="wifi_only" />
|
||||
|
||||
<Preference
|
||||
android:key="equalizer"
|
||||
android:title="Equalizer"
|
||||
|
|
@ -49,7 +82,6 @@
|
|||
<Preference
|
||||
android:key="logout"
|
||||
android:title="Log out" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="@string/settings_about_title">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue