mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-08 16:30:34 +00:00
Pass media browser error as ErrorInfo
This commit is contained in:
parent
b4ce7028d1
commit
fd0ca907aa
@ -26,6 +26,9 @@ import org.schabi.newpipe.database.AppDatabase;
|
|||||||
import org.schabi.newpipe.database.history.model.StreamHistoryEntry;
|
import org.schabi.newpipe.database.history.model.StreamHistoryEntry;
|
||||||
import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry;
|
import org.schabi.newpipe.database.playlist.PlaylistMetadataEntry;
|
||||||
import org.schabi.newpipe.database.playlist.PlaylistStreamEntry;
|
import org.schabi.newpipe.database.playlist.PlaylistStreamEntry;
|
||||||
|
import org.schabi.newpipe.error.ErrorInfo;
|
||||||
|
import org.schabi.newpipe.error.UserAction;
|
||||||
|
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
||||||
import org.schabi.newpipe.local.playlist.LocalPlaylistManager;
|
import org.schabi.newpipe.local.playlist.LocalPlaylistManager;
|
||||||
import org.schabi.newpipe.player.PlayerService;
|
import org.schabi.newpipe.player.PlayerService;
|
||||||
import org.schabi.newpipe.player.playqueue.PlayQueue;
|
import org.schabi.newpipe.player.playqueue.PlayQueue;
|
||||||
@ -219,10 +222,14 @@ public class MediaBrowserConnector implements MediaSessionConnector.PlaybackPrep
|
|||||||
sessionConnector.setCustomErrorMessage(playerService.getString(resId), code);
|
sessionConnector.setCustomErrorMessage(playerService.getString(resId), code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void playbackError(@NonNull final ErrorInfo errorInfo) {
|
||||||
|
playbackError(errorInfo.getMessageStringId(), PlaybackStateCompat.ERROR_CODE_APP_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
private Single<PlayQueue> extractPlayQueueFromMediaId(final String mediaId) {
|
private Single<PlayQueue> extractPlayQueueFromMediaId(final String mediaId) {
|
||||||
final Uri mediaIdUri = Uri.parse(mediaId);
|
final Uri mediaIdUri = Uri.parse(mediaId);
|
||||||
if (mediaIdUri == null) {
|
if (mediaIdUri == null) {
|
||||||
return Single.error(new NullPointerException());
|
return Single.error(new ContentNotAvailableException("Media ID cannot be parsed"));
|
||||||
}
|
}
|
||||||
if (mediaId.startsWith(ID_BOOKMARKS)) {
|
if (mediaId.startsWith(ID_BOOKMARKS)) {
|
||||||
final var path = mediaIdUri.getPathSegments();
|
final var path = mediaIdUri.getPathSegments();
|
||||||
@ -256,7 +263,7 @@ public class MediaBrowserConnector implements MediaSessionConnector.PlaybackPrep
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Single.error(new NullPointerException());
|
return Single.error(new ContentNotAvailableException("Media ID cannot be parsed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -294,8 +301,8 @@ public class MediaBrowserConnector implements MediaSessionConnector.PlaybackPrep
|
|||||||
NavigationHelper.playOnBackgroundPlayer(playerService, playQueue,
|
NavigationHelper.playOnBackgroundPlayer(playerService, playQueue,
|
||||||
playWhenReady);
|
playWhenReady);
|
||||||
},
|
},
|
||||||
throwable -> playbackError(R.string.error_http_not_found,
|
throwable -> playbackError(new ErrorInfo(throwable, UserAction.PLAY_STREAM,
|
||||||
PlaybackStateCompat.ERROR_CODE_NOT_SUPPORTED)
|
"Failed playback of media ID [" + mediaId + "]: "))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user