|
26 | 26 | import org.schabi.newpipe.database.history.model.StreamHistoryEntry;
|
27 | 27 | import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry;
|
28 | 28 | import org.schabi.newpipe.database.playlist.PlaylistStreamEntry;
|
| 29 | +import org.schabi.newpipe.error.ErrorInfo; |
| 30 | +import org.schabi.newpipe.error.UserAction; |
| 31 | +import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException; |
29 | 32 | import org.schabi.newpipe.local.playlist.LocalPlaylistManager;
|
30 | 33 | import org.schabi.newpipe.player.PlayerService;
|
31 | 34 | import org.schabi.newpipe.player.playqueue.PlayQueue;
|
@@ -219,10 +222,14 @@ private void playbackError(@StringRes final int resId, final int code) {
|
219 | 222 | sessionConnector.setCustomErrorMessage(playerService.getString(resId), code);
|
220 | 223 | }
|
221 | 224 |
|
| 225 | + private void playbackError(@NonNull ErrorInfo errorInfo) { |
| 226 | + playbackError(errorInfo.getMessageStringId(), PlaybackStateCompat.ERROR_CODE_APP_ERROR); |
| 227 | + } |
| 228 | + |
222 | 229 | private Single<PlayQueue> extractPlayQueueFromMediaId(final String mediaId) {
|
223 | 230 | final Uri mediaIdUri = Uri.parse(mediaId);
|
224 | 231 | if (mediaIdUri == null) {
|
225 |
| - return Single.error(new NullPointerException()); |
| 232 | + return Single.error(new ContentNotAvailableException("Media ID cannot be parsed")); |
226 | 233 | }
|
227 | 234 | if (mediaId.startsWith(ID_BOOKMARKS)) {
|
228 | 235 | final var path = mediaIdUri.getPathSegments();
|
@@ -256,7 +263,7 @@ private Single<PlayQueue> extractPlayQueueFromMediaId(final String mediaId) {
|
256 | 263 | }
|
257 | 264 | }
|
258 | 265 |
|
259 |
| - return Single.error(new NullPointerException()); |
| 266 | + return Single.error(new ContentNotAvailableException("Media ID cannot be parsed")); |
260 | 267 | }
|
261 | 268 |
|
262 | 269 | @Override
|
@@ -294,8 +301,8 @@ public void onPrepareFromMediaId(@NonNull final String mediaId, final boolean pl
|
294 | 301 | NavigationHelper.playOnBackgroundPlayer(playerService, playQueue,
|
295 | 302 | playWhenReady);
|
296 | 303 | },
|
297 |
| - throwable -> playbackError(R.string.error_http_not_found, |
298 |
| - PlaybackStateCompat.ERROR_CODE_NOT_SUPPORTED) |
| 304 | + throwable -> playbackError(new ErrorInfo(throwable, UserAction.PLAY_STREAM, |
| 305 | + "Failed playback of media ID [" + mediaId + "]: ")) |
299 | 306 | );
|
300 | 307 | }
|
301 | 308 |
|
|
0 commit comments