-Fixed seek problems caused by dynamic timeline .
-Removed debouncing, players are now much more responsive. -Removed some redundant methods.
This commit is contained in:
parent
c38e4190f1
commit
c24d46cf0f
3 changed files with 14 additions and 23 deletions
|
@ -534,6 +534,17 @@ public abstract class BasePlayer implements Player.EventListener,
|
|||
@Override
|
||||
public void onTimelineChanged(Timeline timeline, Object manifest) {
|
||||
if (DEBUG) Log.d(TAG, "onTimelineChanged(), timeline size = " + timeline.getWindowCount());
|
||||
|
||||
if (simpleExoPlayer.getCurrentWindowIndex() != playbackManager.getCurrentSourceIndex()) {
|
||||
if (timeline.getWindowCount() > playbackManager.getCurrentSourceIndex()) {
|
||||
if (DEBUG) Log.d(TAG, "Rewinding to correct window");
|
||||
simpleExoPlayer.seekToDefaultPosition(playbackManager.getCurrentSourceIndex());
|
||||
}
|
||||
}
|
||||
|
||||
if (!simpleExoPlayer.isCurrentWindowDynamic() && simpleExoPlayer.isCurrentWindowSeekable()) {
|
||||
simpleExoPlayer.setPlayWhenReady(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -638,7 +649,6 @@ public abstract class BasePlayer implements Player.EventListener,
|
|||
|
||||
simpleExoPlayer.prepare(playbackManager.getMediaSource());
|
||||
simpleExoPlayer.seekTo(playbackManager.getCurrentSourceIndex(), videoStartPos);
|
||||
simpleExoPlayer.setPlayWhenReady(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -650,20 +660,9 @@ public abstract class BasePlayer implements Player.EventListener,
|
|||
videoThumbnailUrl = info.thumbnail_url;
|
||||
videoTitle = info.name;
|
||||
|
||||
onTimelineChanged(simpleExoPlayer.getCurrentTimeline(), null);
|
||||
|
||||
initThumbnail(videoThumbnailUrl);
|
||||
|
||||
if (simpleExoPlayer.getCurrentWindowIndex() != playbackManager.getCurrentSourceIndex()) {
|
||||
if (DEBUG) Log.w(TAG, "Rewinding to correct window");
|
||||
if (simpleExoPlayer.getCurrentTimeline().getWindowCount() > playbackManager.getCurrentSourceIndex()) {
|
||||
simpleExoPlayer.seekToDefaultPosition(playbackManager.getCurrentSourceIndex());
|
||||
} else {
|
||||
if (DEBUG) Log.w(TAG, "Play Queue out of sync");
|
||||
playbackManager.reset();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
simpleExoPlayer.setPlayWhenReady(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -109,13 +109,6 @@ public class PlaybackManager {
|
|||
load();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
tryBlock();
|
||||
|
||||
resetSources();
|
||||
load();
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
if (playQueueReactor != null) playQueueReactor.cancel();
|
||||
if (disposables != null) disposables.dispose();
|
||||
|
|
|
@ -26,7 +26,6 @@ import io.reactivex.subjects.BehaviorSubject;
|
|||
|
||||
public abstract class PlayQueue implements Serializable {
|
||||
private final String TAG = "PlayQueue@" + Integer.toHexString(hashCode());
|
||||
private final int INDEX_CHANGE_DEBOUNCE = 350;
|
||||
|
||||
public static final boolean DEBUG = true;
|
||||
|
||||
|
@ -59,7 +58,7 @@ public abstract class PlayQueue implements Serializable {
|
|||
|
||||
broadcastReceiver = Flowable.merge(
|
||||
streamsEventBroadcast.toFlowable(BackpressureStrategy.BUFFER),
|
||||
indexEventBroadcast.toFlowable(BackpressureStrategy.BUFFER).debounce(INDEX_CHANGE_DEBOUNCE, TimeUnit.MILLISECONDS)
|
||||
indexEventBroadcast.toFlowable(BackpressureStrategy.BUFFER)
|
||||
).startWith(new InitEvent());
|
||||
|
||||
if (DEBUG) broadcastReceiver.subscribe(getSelfReporter());
|
||||
|
|
Loading…
Reference in a new issue