Merge pull request #3704 from Stypox/keep-failed-streams
Do not remove items generating errors form queue
This commit is contained in:
commit
5cfd8bbb56
|
@ -64,7 +64,6 @@ import org.schabi.newpipe.player.helper.LoadController;
|
||||||
import org.schabi.newpipe.player.helper.MediaSessionManager;
|
import org.schabi.newpipe.player.helper.MediaSessionManager;
|
||||||
import org.schabi.newpipe.player.helper.PlayerDataSource;
|
import org.schabi.newpipe.player.helper.PlayerDataSource;
|
||||||
import org.schabi.newpipe.player.helper.PlayerHelper;
|
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.BasePlayerMediaSession;
|
||||||
import org.schabi.newpipe.player.playback.CustomTrackSelector;
|
import org.schabi.newpipe.player.playback.CustomTrackSelector;
|
||||||
import org.schabi.newpipe.player.playback.MediaSourceManager;
|
import org.schabi.newpipe.player.playback.MediaSourceManager;
|
||||||
|
@ -77,7 +76,6 @@ import org.schabi.newpipe.util.ImageDisplayConstants;
|
||||||
import org.schabi.newpipe.util.SerializedCache;
|
import org.schabi.newpipe.util.SerializedCache;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.UnknownHostException;
|
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
@ -835,16 +833,8 @@ public abstract class BasePlayer implements
|
||||||
final Throwable cause = error.getCause();
|
final Throwable cause = error.getCause();
|
||||||
if (error instanceof BehindLiveWindowException) {
|
if (error instanceof BehindLiveWindowException) {
|
||||||
reload();
|
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 {
|
} else {
|
||||||
playQueue.error(/*noIdeaWhatHappenedAndLetUserChooseWhatToDo=*/true);
|
playQueue.error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -305,25 +305,16 @@ public abstract class PlayQueue implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report an exception for the item at the current index in order and the course of action:
|
* Report an exception for the item at the current index in order and skip to the next one
|
||||||
* if the error can be skipped or the current item should be removed.
|
|
||||||
* <p>
|
* <p>
|
||||||
* This is done as a separate event as the underlying manager may have
|
* This is done as a separate event as the underlying manager may have
|
||||||
* different implementation regarding exceptions.
|
* different implementation regarding exceptions.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
|
||||||
* @param skippable whether the error could be skipped
|
|
||||||
*/
|
*/
|
||||||
public synchronized void error(final boolean skippable) {
|
public synchronized void error() {
|
||||||
final int index = getIndex();
|
final int oldIndex = getIndex();
|
||||||
|
queueIndex.incrementAndGet();
|
||||||
if (skippable) {
|
broadcast(new ErrorEvent(oldIndex, getIndex()));
|
||||||
queueIndex.incrementAndGet();
|
|
||||||
} else {
|
|
||||||
removeInternal(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
broadcast(new ErrorEvent(index, getIndex(), skippable));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void removeInternal(final int removeIndex) {
|
private synchronized void removeInternal(final int removeIndex) {
|
||||||
|
|
|
@ -115,9 +115,6 @@ public class PlayQueueAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||||
break;
|
break;
|
||||||
case ERROR:
|
case ERROR:
|
||||||
final ErrorEvent errorEvent = (ErrorEvent) message;
|
final ErrorEvent errorEvent = (ErrorEvent) message;
|
||||||
if (!errorEvent.isSkippable()) {
|
|
||||||
notifyItemRemoved(errorEvent.getErrorIndex());
|
|
||||||
}
|
|
||||||
notifyItemChanged(errorEvent.getErrorIndex());
|
notifyItemChanged(errorEvent.getErrorIndex());
|
||||||
notifyItemChanged(errorEvent.getQueueIndex());
|
notifyItemChanged(errorEvent.getQueueIndex());
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3,12 +3,10 @@ package org.schabi.newpipe.player.playqueue.events;
|
||||||
public class ErrorEvent implements PlayQueueEvent {
|
public class ErrorEvent implements PlayQueueEvent {
|
||||||
private final int errorIndex;
|
private final int errorIndex;
|
||||||
private final int queueIndex;
|
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.errorIndex = errorIndex;
|
||||||
this.queueIndex = queueIndex;
|
this.queueIndex = queueIndex;
|
||||||
this.skippable = skippable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -23,8 +21,4 @@ public class ErrorEvent implements PlayQueueEvent {
|
||||||
public int getQueueIndex() {
|
public int getQueueIndex() {
|
||||||
return queueIndex;
|
return queueIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSkippable() {
|
|
||||||
return skippable;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue