diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/ExoPlayerWrapper.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/ExoPlayerWrapper.java index 8f7e84561..19ef3d36f 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/ExoPlayerWrapper.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/ExoPlayerWrapper.java @@ -39,6 +39,7 @@ import java.util.concurrent.TimeUnit; public class ExoPlayerWrapper implements IPlayer { private static final String TAG = "ExoPlayerWrapper"; + public static final int ERROR_CODE_OFFSET = 1000; private final Context mContext; private final Disposable bufferingUpdateDisposable; private SimpleExoPlayer mExoPlayer; @@ -109,7 +110,7 @@ public class ExoPlayerWrapper implements IPlayer { @Override public void onPlayerError(ExoPlaybackException error) { if (audioErrorListener != null) { - audioErrorListener.onError(null, 0, 0); + audioErrorListener.onError(null, error.type + ERROR_CODE_OFFSET, 0); } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/MediaPlayerError.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/MediaPlayerError.java index 32d37a67e..8ca8bbf6c 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/MediaPlayerError.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/MediaPlayerError.java @@ -2,30 +2,35 @@ package de.danoeh.antennapod.core.util.playback; import android.content.Context; import android.media.MediaPlayer; - +import com.google.android.exoplayer2.ExoPlaybackException; import de.danoeh.antennapod.core.R; +import de.danoeh.antennapod.core.service.playback.ExoPlayerWrapper; /** Utility class for MediaPlayer errors. */ public class MediaPlayerError { - private MediaPlayerError(){} + private MediaPlayerError(){} - /** Get a human-readable string for a specific error code. */ - public static String getErrorString(Context context, int code) { - int resId; - switch(code) { - case MediaPlayer.MEDIA_ERROR_SERVER_DIED: - resId = R.string.playback_error_server_died; - break; - case MediaPlayer.MEDIA_ERROR_UNSUPPORTED: - resId = R.string.playback_error_unsupported; - break; - case MediaPlayer.MEDIA_ERROR_TIMED_OUT: - resId = R.string.playback_error_timeout; - break; - default: - resId = R.string.playback_error_unknown; - break; - } - return context.getString(resId) + " (" + code + ")"; - } + /** Get a human-readable string for a specific error code. */ + public static String getErrorString(Context context, int code) { + int resId; + switch (code) { + case MediaPlayer.MEDIA_ERROR_SERVER_DIED: + resId = R.string.playback_error_server_died; + break; + case MediaPlayer.MEDIA_ERROR_UNSUPPORTED: // fall-through + case ExoPlayerWrapper.ERROR_CODE_OFFSET + ExoPlaybackException.TYPE_RENDERER: + resId = R.string.playback_error_unsupported; + break; + case MediaPlayer.MEDIA_ERROR_TIMED_OUT: + resId = R.string.playback_error_timeout; + break; + case ExoPlayerWrapper.ERROR_CODE_OFFSET + ExoPlaybackException.TYPE_SOURCE: + resId = R.string.playback_error_source; + break; + default: + resId = R.string.playback_error_unknown; + break; + } + return context.getString(resId) + " (" + code + ")"; + } } diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 8cb9f7b84..72388725c 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -283,6 +283,7 @@ Server died Unsupported media type Operation timed out + Unable to access media file Unknown Error No media playing 00:00:00