switch to embed player fix

This commit is contained in:
Yuriy Liskov
2025-06-09 16:20:09 +03:00
parent 6b0e40b9ca
commit 20736848ce

View File

@@ -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