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

Do not remove items generating errors form queue #3704

Merged
merged 1 commit into from
Jun 15, 2020
Merged
Show file tree
Hide file tree
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
12 changes: 1 addition & 11 deletions app/src/main/java/org/schabi/newpipe/player/BasePlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import org.schabi.newpipe.player.helper.MediaSessionManager;
import org.schabi.newpipe.player.helper.PlayerDataSource;
import org.schabi.newpipe.player.helper.PlayerHelper;
import org.schabi.newpipe.player.mediasource.FailedMediaSource;
import org.schabi.newpipe.player.playback.BasePlayerMediaSession;
import org.schabi.newpipe.player.playback.CustomTrackSelector;
import org.schabi.newpipe.player.playback.MediaSourceManager;
Expand All @@ -77,7 +76,6 @@
import org.schabi.newpipe.util.SerializedCache;

import java.io.IOException;
import java.net.UnknownHostException;

import io.reactivex.Observable;
import io.reactivex.disposables.CompositeDisposable;
Expand Down Expand Up @@ -835,16 +833,8 @@ private void processSourceError(final IOException error) {
final Throwable cause = error.getCause();
if (error instanceof BehindLiveWindowException) {
reload();
} else if (cause instanceof UnknownHostException) {
playQueue.error(/*isNetworkProblem=*/true);
} else if (isCurrentWindowValid()) {
playQueue.error(/*isTransitioningToBadStream=*/true);
} else if (cause instanceof FailedMediaSource.MediaSourceResolutionException) {
playQueue.error(/*recoverableWithNoAvailableStream=*/false);
} else if (cause instanceof FailedMediaSource.StreamInfoLoadException) {
playQueue.error(/*recoverableIfLoadFailsWhenNetworkIsFine=*/false);
} else {
playQueue.error(/*noIdeaWhatHappenedAndLetUserChooseWhatToDo=*/true);
playQueue.error();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,25 +305,16 @@ public synchronized void remove(final int index) {
}

/**
* Report an exception for the item at the current index in order and the course of action:
* if the error can be skipped or the current item should be removed.
* Report an exception for the item at the current index in order and skip to the next one
* <p>
* This is done as a separate event as the underlying manager may have
* different implementation regarding exceptions.
* </p>
*
* @param skippable whether the error could be skipped
*/
public synchronized void error(final boolean skippable) {
final int index = getIndex();

if (skippable) {
queueIndex.incrementAndGet();
} else {
removeInternal(index);
}

broadcast(new ErrorEvent(index, getIndex(), skippable));
public synchronized void error() {
final int oldIndex = getIndex();
queueIndex.incrementAndGet();
broadcast(new ErrorEvent(oldIndex, getIndex()));
}

private synchronized void removeInternal(final int removeIndex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ private void onPlayQueueChanged(final PlayQueueEvent message) {
break;
case ERROR:
final ErrorEvent errorEvent = (ErrorEvent) message;
if (!errorEvent.isSkippable()) {
notifyItemRemoved(errorEvent.getErrorIndex());
}
notifyItemChanged(errorEvent.getErrorIndex());
notifyItemChanged(errorEvent.getQueueIndex());
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
public class ErrorEvent implements PlayQueueEvent {
private final int errorIndex;
private final int queueIndex;
private final boolean skippable;

public ErrorEvent(final int errorIndex, final int queueIndex, final boolean skippable) {
public ErrorEvent(final int errorIndex, final int queueIndex) {
this.errorIndex = errorIndex;
this.queueIndex = queueIndex;
this.skippable = skippable;
}

@Override
Expand All @@ -23,8 +21,4 @@ public int getErrorIndex() {
public int getQueueIndex() {
return queueIndex;
}

public boolean isSkippable() {
return skippable;
}
}