mirror of
https://github.com/yuliskov/SmartTube.git
synced 2026-01-26 08:30:26 -06:00
switch to embed player fix
This commit is contained in:
@@ -50,7 +50,7 @@ public class PlaybackPresenter extends BasePresenter<PlaybackView> implements Pl
|
||||
private Video mPendingVideo;
|
||||
// Fix for using destroyed view
|
||||
private WeakReference<PlaybackView> mPlayer = new WeakReference<>(null);
|
||||
private long mNewVideoStartedTimeMs;
|
||||
private boolean mIsEmbedPlayerStarted;
|
||||
|
||||
private PlaybackPresenter(Context context) {
|
||||
super(context);
|
||||
@@ -136,6 +136,7 @@ public class PlaybackPresenter extends BasePresenter<PlaybackView> implements Pl
|
||||
}
|
||||
|
||||
getViewManager().startView(PlaybackView.class);
|
||||
mIsEmbedPlayerStarted = false;
|
||||
}
|
||||
|
||||
public Video getVideo() {
|
||||
@@ -210,7 +211,7 @@ public class PlaybackPresenter extends BasePresenter<PlaybackView> implements Pl
|
||||
|
||||
// Fix playing the previous video when switching between embed and fullscreen players.
|
||||
// E.g. when the user pressed back on the Channel content screen
|
||||
if (view != null && view.getVideo() != null && isNewVideoExpired()) {
|
||||
if (view != null && view.getVideo() != null && mIsEmbedPlayerStarted) {
|
||||
mVideo = new WeakReference<>(view.getVideo());
|
||||
Playlist.instance().add(view.getVideo()); // don't show queue
|
||||
}
|
||||
@@ -241,7 +242,7 @@ public class PlaybackPresenter extends BasePresenter<PlaybackView> implements Pl
|
||||
public void onNewVideo(Video video) {
|
||||
process(listener -> listener.onNewVideo(video));
|
||||
mVideo = new WeakReference<>(video);
|
||||
mNewVideoStartedTimeMs = System.currentTimeMillis();
|
||||
mIsEmbedPlayerStarted = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -271,10 +272,6 @@ public class PlaybackPresenter extends BasePresenter<PlaybackView> implements Pl
|
||||
Utils.process(mEventListeners, processor);
|
||||
}
|
||||
|
||||
private boolean isNewVideoExpired() {
|
||||
return System.currentTimeMillis() - mNewVideoStartedTimeMs > 500;
|
||||
}
|
||||
|
||||
// End Helpers
|
||||
|
||||
// Common events
|
||||
|
||||
Reference in New Issue
Block a user