diff --git a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/PlayerControllerFragment.java b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/PlayerControllerFragment.java index a1e55613..917573f6 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/PlayerControllerFragment.java +++ b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/PlayerControllerFragment.java @@ -8,6 +8,7 @@ import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageView; import android.widget.TextView; +import android.widget.Toast; import android.widget.ToggleButton; import androidx.annotation.NonNull; @@ -51,6 +52,7 @@ public class PlayerControllerFragment extends Fragment { private Chip playerMediaExtension; private TextView playerMediaBitrate; private ImageView playerMediaTranscodingIcon; + private ImageView playerMediaTranscodingPriorityIcon; private Chip playerMediaTranscodedExtension; private TextView playerMediaTranscodedBitrate; @@ -71,6 +73,7 @@ public class PlayerControllerFragment extends Fragment { initCoverLyricsSlideView(); initMediaListenable(); initArtistLabelButton(); + initTranscodingInfo(); return view; } @@ -104,6 +107,7 @@ public class PlayerControllerFragment extends Fragment { playerMediaExtension = bind.getRoot().findViewById(R.id.player_media_extension); playerMediaBitrate = bind.getRoot().findViewById(R.id.player_media_bitrate); playerMediaTranscodingIcon = bind.getRoot().findViewById(R.id.player_media_transcoding_audio); + playerMediaTranscodingPriorityIcon = bind.getRoot().findViewById(R.id.player_media_server_transcode_priority); playerMediaTranscodedExtension = bind.getRoot().findViewById(R.id.player_media_transcoded_extension); playerMediaTranscodedBitrate = bind.getRoot().findViewById(R.id.player_media_transcoded_bitrate); } @@ -166,7 +170,6 @@ public class PlayerControllerFragment extends Fragment { playerMediaBitrate.setVisibility(View.GONE); } else { playerMediaBitrate.setVisibility(View.VISIBLE); - playerMediaBitrate.setText(bitrate); } } @@ -177,19 +180,28 @@ public class PlayerControllerFragment extends Fragment { : "Original"; if (transcodingExtension.equals("raw") && transcodingBitrate.equals("Original")) { + playerMediaTranscodingPriorityIcon.setVisibility(View.GONE); playerMediaTranscodingIcon.setVisibility(View.GONE); playerMediaTranscodedBitrate.setVisibility(View.GONE); playerMediaTranscodedExtension.setVisibility(View.GONE); } else { + playerMediaTranscodingPriorityIcon.setVisibility(View.GONE); playerMediaTranscodingIcon.setVisibility(View.VISIBLE); playerMediaTranscodedBitrate.setVisibility(View.VISIBLE); playerMediaTranscodedExtension.setVisibility(View.VISIBLE); - playerMediaTranscodedExtension.setText(transcodingExtension); playerMediaTranscodedBitrate.setText(transcodingBitrate); } if (mediaMetadata.extras != null && mediaMetadata.extras.getString("uri", "").contains(Constants.DOWNLOAD_URI)) { + playerMediaTranscodingPriorityIcon.setVisibility(View.GONE); + playerMediaTranscodingIcon.setVisibility(View.GONE); + playerMediaTranscodedBitrate.setVisibility(View.GONE); + playerMediaTranscodedExtension.setVisibility(View.GONE); + } + + if (Preferences.isServerPrioritized() && mediaMetadata.extras != null && !mediaMetadata.extras.getString("uri", "").contains(Constants.DOWNLOAD_URI)) { + playerMediaTranscodingPriorityIcon.setVisibility(View.VISIBLE); playerMediaTranscodingIcon.setVisibility(View.GONE); playerMediaTranscodedBitrate.setVisibility(View.GONE); playerMediaTranscodedExtension.setVisibility(View.GONE); @@ -293,6 +305,13 @@ public class PlayerControllerFragment extends Fragment { }); } + private void initTranscodingInfo() { + playerMediaTranscodingPriorityIcon.setOnLongClickListener(view -> { + Toast.makeText(requireActivity(), R.string.settings_audio_transcode_priority_toast, Toast.LENGTH_SHORT).show(); + return true; + }); + } + private void initPlaybackSpeedButton(MediaBrowser mediaBrowser) { playbackSpeedButton.setOnClickListener(view -> { float currentSpeed = Preferences.getPlaybackSpeed(); 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 6795df92..c880ae8d 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/util/MusicUtil.java +++ b/app/src/main/java/com/cappielloantonio/tempo/util/MusicUtil.java @@ -41,8 +41,11 @@ public class MusicUtil { if (params.containsKey("c") && params.get("c") != null) uri.append("&c=").append(params.get("c")); - uri.append("&maxBitRate=").append(getBitratePreference()); - uri.append("&format=").append(getTranscodingFormatPreference()); + if (!Preferences.isServerPrioritized()) + uri.append("&maxBitRate=").append(getBitratePreference()); + if (!Preferences.isServerPrioritized()) + uri.append("&format=").append(getTranscodingFormatPreference()); + uri.append("&id=").append(id); Log.d(TAG, "getStreamUri: " + uri); 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 cdab64fa..cc77e8f6 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt +++ b/app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt @@ -32,6 +32,7 @@ object Preferences { private const val RADIO_SECTION_VISIBILITY = "radio_section_visibility" private const val MUSIC_DIRECTORY_SECTION_VISIBILITY = "music_directory_section_visibility" private const val REPLAY_GAIN_MODE = "replay_gain_mode" + private const val AUDIO_TRANSCODE_PRIORITY = "audio_transcode_priority" @JvmStatic fun getServer(): String? { @@ -252,4 +253,9 @@ object Preferences { fun getReplayGainMode(): String? { return App.getInstance().preferences.getString(REPLAY_GAIN_MODE, "disabled") } + + @JvmStatic + fun isServerPrioritized(): Boolean { + return App.getInstance().preferences.getBoolean(AUDIO_TRANSCODE_PRIORITY, false) + } } \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_server_transcode_priority.xml b/app/src/main/res/drawable/ic_server_transcode_priority.xml new file mode 100644 index 00000000..5af6feaa --- /dev/null +++ b/app/src/main/res/drawable/ic_server_transcode_priority.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/layout/inner_fragment_player_controller_layout.xml b/app/src/main/res/layout/inner_fragment_player_controller_layout.xml index 3d84b535..750c61e8 100644 --- a/app/src/main/res/layout/inner_fragment_player_controller_layout.xml +++ b/app/src/main/res/layout/inner_fragment_player_controller_layout.xml @@ -41,6 +41,13 @@ android:src="@drawable/ic_transcode" android:visibility="gone" /> + + Search Settings %1$.2fx + Server Priority Playlist Catalogue Browse Playlists No playlists created @@ -170,10 +171,13 @@ The requested server is unavailable. If you choose to continue this dialog will not appear for the next hour. Tempo is an open source and lightweight music client for Subsonic, designed and built natively for Android. About + 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 Transcode format in mobile Transcode format in Wi-Fi Size of artwork cache - In order to reduce data consumption, avoid downloading covers + In order to reduce data consumption, avoid downloading covers. Limit mobile data usage Adjust audio settings Equalizer @@ -242,7 +246,7 @@ Sync starred tracks https://undraw.co/ unDraw - A special thanks goes to unDraw without whose illustrations we could not have made this application more beautiful + A special thanks goes to unDraw without whose illustrations we could not have made this application more beautiful. Radio stations New releases Best of @@ -261,6 +265,4 @@ Name Random No description available - - Hello blank fragment \ No newline at end of file diff --git a/app/src/main/res/xml/global_preferences.xml b/app/src/main/res/xml/global_preferences.xml index c737e51c..c7904a33 100644 --- a/app/src/main/res/xml/global_preferences.xml +++ b/app/src/main/res/xml/global_preferences.xml @@ -102,6 +102,12 @@ app:selectable="false" app:summary="@string/settings_summary_transcoding" /> + +