diff --git a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java
index 034fd71fc..bacb5972f 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java
@@ -30,11 +30,11 @@ import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.SeekBar;
import androidx.annotation.Nullable;
-import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import androidx.core.view.WindowCompat;
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
import com.bumptech.glide.Glide;
import de.danoeh.antennapod.R;
+import de.danoeh.antennapod.dialog.MediaPlayerErrorDialog;
import de.danoeh.antennapod.dialog.VariableSpeedDialog;
import de.danoeh.antennapod.event.playback.BufferUpdateEvent;
import de.danoeh.antennapod.event.playback.PlaybackPositionEvent;
@@ -514,11 +514,7 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMediaPlayerError(PlayerErrorEvent event) {
- final MaterialAlertDialogBuilder errorDialog = new MaterialAlertDialogBuilder(VideoplayerActivity.this);
- errorDialog.setTitle(R.string.error_label);
- errorDialog.setMessage(event.getMessage());
- errorDialog.setNeutralButton(android.R.string.ok, (dialog, which) -> finish());
- errorDialog.show();
+ MediaPlayerErrorDialog.show(this, event);
}
@Override
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/MediaPlayerErrorDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/MediaPlayerErrorDialog.java
new file mode 100644
index 000000000..ab5dde92d
--- /dev/null
+++ b/app/src/main/java/de/danoeh/antennapod/dialog/MediaPlayerErrorDialog.java
@@ -0,0 +1,37 @@
+package de.danoeh.antennapod.dialog;
+
+import android.app.Activity;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.style.ForegroundColorSpan;
+import com.google.android.material.bottomsheet.BottomSheetBehavior;
+import com.google.android.material.dialog.MaterialAlertDialogBuilder;
+import com.google.android.material.snackbar.Snackbar;
+import de.danoeh.antennapod.R;
+import de.danoeh.antennapod.activity.MainActivity;
+import de.danoeh.antennapod.event.PlayerErrorEvent;
+import de.danoeh.antennapod.storage.preferences.UserPreferences;
+
+public class MediaPlayerErrorDialog {
+ public static void show(Activity activity, PlayerErrorEvent event) {
+ final MaterialAlertDialogBuilder errorDialog = new MaterialAlertDialogBuilder(activity);
+ errorDialog.setTitle(R.string.error_label);
+
+ String genericMessage = activity.getString(R.string.playback_error_generic);
+ SpannableString errorMessage = new SpannableString(genericMessage + "\n\n" + event.getMessage());
+ errorMessage.setSpan(new ForegroundColorSpan(0x88888888),
+ genericMessage.length(), errorMessage.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+
+ errorDialog.setMessage(errorMessage);
+ errorDialog.setPositiveButton(android.R.string.ok, (dialog, which) ->
+ ((MainActivity) activity).getBottomSheet().setState(BottomSheetBehavior.STATE_COLLAPSED));
+ if (!UserPreferences.useExoplayer()) {
+ errorDialog.setNeutralButton(R.string.media_player_switch_to_exoplayer, (dialog, which) -> {
+ UserPreferences.enableExoplayer();
+ ((MainActivity) activity).showSnackbarAbovePlayer(
+ R.string.media_player_switched_to_exoplayer, Snackbar.LENGTH_LONG);
+ });
+ }
+ errorDialog.create().show();
+ }
+}
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java
index 51cb28eb8..e5aac5fa5 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/AudioPlayerFragment.java
@@ -15,7 +15,6 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.appbar.MaterialToolbar;
import androidx.cardview.widget.CardView;
import androidx.fragment.app.Fragment;
@@ -25,10 +24,10 @@ import androidx.viewpager2.widget.ViewPager2;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.elevation.SurfaceColors;
-import com.google.android.material.snackbar.Snackbar;
import de.danoeh.antennapod.core.receiver.MediaButtonReceiver;
import de.danoeh.antennapod.core.util.playback.PlaybackController;
+import de.danoeh.antennapod.dialog.MediaPlayerErrorDialog;
import de.danoeh.antennapod.event.playback.BufferUpdateEvent;
import de.danoeh.antennapod.event.playback.PlaybackServiceEvent;
import de.danoeh.antennapod.event.PlayerErrorEvent;
@@ -396,19 +395,7 @@ public class AudioPlayerFragment extends Fragment implements
@Subscribe(threadMode = ThreadMode.MAIN)
public void mediaPlayerError(PlayerErrorEvent event) {
- final MaterialAlertDialogBuilder errorDialog = new MaterialAlertDialogBuilder(getContext());
- errorDialog.setTitle(R.string.error_label);
- errorDialog.setMessage(event.getMessage());
- errorDialog.setPositiveButton(android.R.string.ok, (dialog, which) ->
- ((MainActivity) getActivity()).getBottomSheet().setState(BottomSheetBehavior.STATE_COLLAPSED));
- if (!UserPreferences.useExoplayer()) {
- errorDialog.setNeutralButton(R.string.media_player_switch_to_exoplayer, (dialog, which) -> {
- UserPreferences.enableExoplayer();
- ((MainActivity) getActivity()).showSnackbarAbovePlayer(
- R.string.media_player_switched_to_exoplayer, Snackbar.LENGTH_LONG);
- });
- }
- errorDialog.create().show();
+ MediaPlayerErrorDialog.show(getActivity(), event);
}
@Override
diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml
index fb4d24f7a..b33aa2349 100644
--- a/ui/i18n/src/main/res/values/strings.xml
+++ b/ui/i18n/src/main/res/values/strings.xml
@@ -310,6 +310,7 @@
Allow temporarily
+
Server died
Unsupported media type
Operation timed out