Merge branch 'dev' into giga-postprocessing

This commit is contained in:
Christian Schabesberger 2018-12-10 12:12:38 +01:00 committed by GitHub
commit 6035be9ce6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 4 deletions

View File

@ -145,7 +145,7 @@ public class PlayerHelper {
final StreamInfoItem nextVideo = info.getNextVideo(); final StreamInfoItem nextVideo = info.getNextVideo();
if (nextVideo != null && !urls.contains(nextVideo.getUrl())) { if (nextVideo != null && !urls.contains(nextVideo.getUrl())) {
return new SinglePlayQueue(nextVideo); return getAutoQueuedSinglePlayQueue(nextVideo);
} }
final List<InfoItem> relatedItems = info.getRelatedStreams(); final List<InfoItem> relatedItems = info.getRelatedStreams();
@ -158,7 +158,7 @@ public class PlayerHelper {
} }
} }
Collections.shuffle(autoQueueItems); Collections.shuffle(autoQueueItems);
return autoQueueItems.isEmpty() ? null : new SinglePlayQueue(autoQueueItems.get(0)); return autoQueueItems.isEmpty() ? null : getAutoQueuedSinglePlayQueue(autoQueueItems.get(0));
} }
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@ -350,4 +350,10 @@ public class PlayerHelper {
return getPreferences(context).getString(context.getString(R.string.minimize_on_exit_key), return getPreferences(context).getString(context.getString(R.string.minimize_on_exit_key),
key); key);
} }
private static SinglePlayQueue getAutoQueuedSinglePlayQueue(StreamInfoItem streamInfoItem) {
SinglePlayQueue singlePlayQueue = new SinglePlayQueue(streamInfoItem);
singlePlayQueue.getItem().setAutoQueued(true);
return singlePlayQueue;
}
} }

View File

@ -233,6 +233,9 @@ public abstract class PlayQueue implements Serializable {
backup.addAll(itemList); backup.addAll(itemList);
Collections.shuffle(itemList); Collections.shuffle(itemList);
} }
if (!streams.isEmpty() && streams.get(streams.size() - 1).isAutoQueued() && !itemList.get(0).isAutoQueued()) {
streams.remove(streams.size() - 1);
}
streams.addAll(itemList); streams.addAll(itemList);
broadcast(new AppendEvent(itemList.size())); broadcast(new AppendEvent(itemList.size()));
@ -314,7 +317,9 @@ public abstract class PlayQueue implements Serializable {
queueIndex.incrementAndGet(); queueIndex.incrementAndGet();
} }
streams.add(target, streams.remove(source)); PlayQueueItem playQueueItem = streams.remove(source);
playQueueItem.setAutoQueued(false);
streams.add(target, playQueueItem);
broadcast(new MoveEvent(source, target)); broadcast(new MoveEvent(source, target));
} }

View File

@ -25,9 +25,10 @@ public class PlayQueueItem implements Serializable {
@NonNull final private String uploader; @NonNull final private String uploader;
@NonNull final private StreamType streamType; @NonNull final private StreamType streamType;
private boolean isAutoQueued;
private long recoveryPosition; private long recoveryPosition;
private Throwable error; private Throwable error;
PlayQueueItem(@NonNull final StreamInfo info) { PlayQueueItem(@NonNull final StreamInfo info) {
this(info.getName(), info.getUrl(), info.getServiceId(), info.getDuration(), this(info.getName(), info.getUrl(), info.getServiceId(), info.getDuration(),
info.getThumbnailUrl(), info.getUploaderName(), info.getStreamType()); info.getThumbnailUrl(), info.getUploaderName(), info.getStreamType());
@ -105,6 +106,14 @@ public class PlayQueueItem implements Serializable {
.doOnError(throwable -> error = throwable); .doOnError(throwable -> error = throwable);
} }
public boolean isAutoQueued() {
return isAutoQueued;
}
public void setAutoQueued(boolean autoQueued) {
isAutoQueued = autoQueued;
}
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Item States, keep external access out // Item States, keep external access out
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////