fix: fix the hardware back button
This commit is contained in:
parent
810c62407f
commit
622f9d3f3f
@ -6,6 +6,8 @@ import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
|
||||
import com.google.android.exoplayer2.ui.PlayerControlView;
|
||||
|
||||
public class FullScreenPlayerView extends Dialog {
|
||||
@ -13,15 +15,23 @@ public class FullScreenPlayerView extends Dialog {
|
||||
private final ExoPlayerView exoPlayerView;
|
||||
private ViewGroup parent;
|
||||
private final FrameLayout containerView;
|
||||
private final OnBackPressedCallback onBackPressedCallback;
|
||||
|
||||
public FullScreenPlayerView(Context context, ExoPlayerView exoPlayerView, PlayerControlView playerControlView) {
|
||||
public FullScreenPlayerView(Context context, ExoPlayerView exoPlayerView, PlayerControlView playerControlView, OnBackPressedCallback onBackPressedCallback) {
|
||||
super(context, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
|
||||
this.playerControlView = playerControlView;
|
||||
this.exoPlayerView = exoPlayerView;
|
||||
this.onBackPressedCallback = onBackPressedCallback;
|
||||
containerView = new FrameLayout(context);
|
||||
setContentView(containerView, generateDefaultLayoutParams());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
onBackPressedCallback.handleOnBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
parent = (FrameLayout)(exoPlayerView.getParent());
|
||||
|
@ -17,6 +17,8 @@ import android.view.accessibility.CaptioningManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
|
||||
import com.brentvatne.react.R;
|
||||
import com.brentvatne.receiver.AudioBecomingNoisyReceiver;
|
||||
import com.brentvatne.receiver.BecomingNoisyListener;
|
||||
@ -669,7 +671,12 @@ class ReactExoplayerView extends FrameLayout implements
|
||||
setControls(controls);
|
||||
applyModifiers();
|
||||
startBufferCheckTimer();
|
||||
fullScreenPlayerView = new FullScreenPlayerView(getContext(), exoPlayerView, playerControlView);
|
||||
fullScreenPlayerView = new FullScreenPlayerView(getContext(), exoPlayerView, playerControlView, new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
setFullscreen(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private DrmSessionManager buildDrmSessionManager(UUID uuid, String licenseUrl, String[] keyRequestPropertiesArray) throws UnsupportedDrmException {
|
||||
|
Loading…
Reference in New Issue
Block a user