-Added separate events for play queue index removal.

pull/680/head
John Zhen M 2017-08-31 17:47:56 -07:00 zatwierdzone przez John Zhen Mo
rodzic dcdcf17f5e
commit 701320b100
3 zmienionych plików z 29 dodań i 9 usunięć

Wyświetl plik

@ -70,6 +70,7 @@ import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListene
import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.stream_info.StreamInfo;
import org.schabi.newpipe.playlist.PlayQueue;
import java.io.File;
@ -564,6 +565,17 @@ public abstract class BasePlayer implements Player.EventListener,
if (currentState != STATE_PLAYING) changeState(STATE_PLAYING);
}
@Override
public void sync(final StreamInfo info) {
}
@Override
public MediaSource sourceOf(final StreamInfo info) {
return null;
}
/*//////////////////////////////////////////////////////////////////////////
// General Player
//////////////////////////////////////////////////////////////////////////*/

Wyświetl plik

@ -31,9 +31,9 @@ public class PlaybackManager {
interface PlaybackListener {
void block();
void unblock();
void sync();
MediaSource sourceOf(StreamInfo info);
void sync(final StreamInfo info);
MediaSource sourceOf(final StreamInfo info);
}
public PlaybackManager(@NonNull final PlaybackListener listener,
@ -58,6 +58,10 @@ public class PlaybackManager {
load(0);
}
public void changeSource(final int index) {
}
public void refreshMedia(final int newMediaIndex) {
if (newMediaIndex == sourceIndex) return;
@ -67,7 +71,7 @@ public class PlaybackManager {
queueSource.remove(0);
} else {
//something went wrong
onInit();
init();
}
}
@ -124,7 +128,7 @@ public class PlaybackManager {
if (mediaSource.getSize() > 0 && queueSource.size() > 0) listener.unblock();
}
private void onInit() {
private void init() {
listener.block();
load();
}
@ -156,7 +160,7 @@ public class PlaybackManager {
switch (event) {
case INIT:
onInit();
init();
break;
case APPEND:
load();

Wyświetl plik

@ -5,7 +5,6 @@ import android.support.annotation.NonNull;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.stream_info.StreamInfo;
import java.util.ArrayList;
import java.util.Collection;
@ -15,7 +14,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import io.reactivex.BackpressureStrategy;
import io.reactivex.Flowable;
import io.reactivex.Maybe;
import io.reactivex.subjects.BehaviorSubject;
public abstract class PlayQueue {
@ -94,8 +92,14 @@ public abstract class PlayQueue {
}
public void remove(final int index) {
if (index < streams.size()) {
streams.remove(index);
if (index >= streams.size()) return;
final boolean isCurrent = index == queueIndex.get();
streams.remove(index);
if (isCurrent) {
broadcast(PlayQueueEvent.REMOVE_CURRENT);
} else {
broadcast(PlayQueueEvent.REMOVE);
}
}