Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added response to error code for bad http status #9167

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ public final class Player implements PlaybackListener, Listener {
@NonNull private final SharedPreferences prefs;
@NonNull private final HistoryRecordManager recordManager;

/*//////////////////////////////////////////////////////////////////////////
// Error states
//////////////////////////////////////////////////////////////////////////*/

private int badHttpStatusRetry = 0;

/*//////////////////////////////////////////////////////////////////////////
// Constructor
Expand Down Expand Up @@ -1407,6 +1412,17 @@ public void onPlayerError(@NonNull final PlaybackException error) {
break;
case ERROR_CODE_IO_INVALID_HTTP_CONTENT_TYPE:
case ERROR_CODE_IO_BAD_HTTP_STATUS:
if (badHttpStatusRetry < 3) {
badHttpStatusRetry += 1;
isCatchableException = true;
// Clears metadata cache and then reloads playback
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add more comments here, with what you have in the PR description.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if you can only clear the cache of the currently playing video.

However, I have tested the badHttpStatusRetry variable thing and it does reset back to 0 automatically whenever the player changes. For example, if you watch a different video. I think it's probably because the Player.java class gets created every time you watch a new video.

InfoCache.getInstance().clearCache();
setRecovery();
reloadPlayQueueManager();
} else {
isCatchableException = false;
}
break;
case ERROR_CODE_IO_FILE_NOT_FOUND:
case ERROR_CODE_IO_NO_PERMISSION:
case ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED:
Expand Down