-Added separate events for play queue index removal.
This commit is contained in:
parent
dcdcf17f5e
commit
701320b100
|
@ -70,6 +70,7 @@ import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListene
|
||||||
|
|
||||||
import org.schabi.newpipe.Downloader;
|
import org.schabi.newpipe.Downloader;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
import org.schabi.newpipe.extractor.stream_info.StreamInfo;
|
||||||
import org.schabi.newpipe.playlist.PlayQueue;
|
import org.schabi.newpipe.playlist.PlayQueue;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -564,6 +565,17 @@ public abstract class BasePlayer implements Player.EventListener,
|
||||||
if (currentState != STATE_PLAYING) changeState(STATE_PLAYING);
|
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
|
// General Player
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
|
@ -31,9 +31,9 @@ public class PlaybackManager {
|
||||||
interface PlaybackListener {
|
interface PlaybackListener {
|
||||||
void block();
|
void block();
|
||||||
void unblock();
|
void unblock();
|
||||||
void sync();
|
|
||||||
|
|
||||||
MediaSource sourceOf(StreamInfo info);
|
void sync(final StreamInfo info);
|
||||||
|
MediaSource sourceOf(final StreamInfo info);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlaybackManager(@NonNull final PlaybackListener listener,
|
public PlaybackManager(@NonNull final PlaybackListener listener,
|
||||||
|
@ -58,6 +58,10 @@ public class PlaybackManager {
|
||||||
load(0);
|
load(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void changeSource(final int index) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void refreshMedia(final int newMediaIndex) {
|
public void refreshMedia(final int newMediaIndex) {
|
||||||
if (newMediaIndex == sourceIndex) return;
|
if (newMediaIndex == sourceIndex) return;
|
||||||
|
|
||||||
|
@ -67,7 +71,7 @@ public class PlaybackManager {
|
||||||
queueSource.remove(0);
|
queueSource.remove(0);
|
||||||
} else {
|
} else {
|
||||||
//something went wrong
|
//something went wrong
|
||||||
onInit();
|
init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +128,7 @@ public class PlaybackManager {
|
||||||
if (mediaSource.getSize() > 0 && queueSource.size() > 0) listener.unblock();
|
if (mediaSource.getSize() > 0 && queueSource.size() > 0) listener.unblock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onInit() {
|
private void init() {
|
||||||
listener.block();
|
listener.block();
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
@ -156,7 +160,7 @@ public class PlaybackManager {
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case INIT:
|
case INIT:
|
||||||
onInit();
|
init();
|
||||||
break;
|
break;
|
||||||
case APPEND:
|
case APPEND:
|
||||||
load();
|
load();
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.support.annotation.NonNull;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.stream_info.StreamInfo;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -15,7 +14,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import io.reactivex.BackpressureStrategy;
|
import io.reactivex.BackpressureStrategy;
|
||||||
import io.reactivex.Flowable;
|
import io.reactivex.Flowable;
|
||||||
import io.reactivex.Maybe;
|
|
||||||
import io.reactivex.subjects.BehaviorSubject;
|
import io.reactivex.subjects.BehaviorSubject;
|
||||||
|
|
||||||
public abstract class PlayQueue {
|
public abstract class PlayQueue {
|
||||||
|
@ -94,8 +92,14 @@ public abstract class PlayQueue {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(final int index) {
|
public void remove(final int index) {
|
||||||
if (index < streams.size()) {
|
if (index >= streams.size()) return;
|
||||||
streams.remove(index);
|
final boolean isCurrent = index == queueIndex.get();
|
||||||
|
|
||||||
|
streams.remove(index);
|
||||||
|
|
||||||
|
if (isCurrent) {
|
||||||
|
broadcast(PlayQueueEvent.REMOVE_CURRENT);
|
||||||
|
} else {
|
||||||
broadcast(PlayQueueEvent.REMOVE);
|
broadcast(PlayQueueEvent.REMOVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue