From debc0cb3c60d1ac54218093dc06a92a7417ff3d0 Mon Sep 17 00:00:00 2001 From: Ibrahim Sulaiman Date: Fri, 25 Jan 2019 15:54:53 +0530 Subject: [PATCH] Resolved the playercontrol UI issue and also handled the controls prop state --- .../exoplayer/ReactExoplayerView.java | 11 ++- .../res/layout/exo_player_control_view.xml | 75 +++++++++++++++++++ 2 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 android-exoplayer/src/main/res/layout/exo_player_control_view.xml diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 3d500d17..e491ccb4 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -275,7 +275,9 @@ class ReactExoplayerView extends FrameLayout implements * Initializing Player control */ private void initializePlayerControl() { - playerControlView = new PlayerControlView(getContext()); + if(playerControlView == null) { + playerControlView = new PlayerControlView(getContext()); + } LayoutParams layoutParams = new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); @@ -284,6 +286,7 @@ class ReactExoplayerView extends FrameLayout implements //Setting the player for the playerControlView playerControlView.setPlayer(player); + playerControlView.setVisibility(VISIBLE); //Invoking onClick event for exoplayerView exoPlayerView.setOnClickListener(new OnClickListener() { @@ -1104,9 +1107,13 @@ class ReactExoplayerView extends FrameLayout implements * @param controls value of the controls prop passed from react-native */ public void setControls(boolean controls) { - if(controls && (exoPlayerView != null)) { + if(controls && (exoPlayerView != null)) { //Initialize playerControlView initializePlayerControl(); + } else { + if(getChildAt(1) instanceof PlayerControlView && (exoPlayerView != null)){ + removeViewAt(1); + } } } } diff --git a/android-exoplayer/src/main/res/layout/exo_player_control_view.xml b/android-exoplayer/src/main/res/layout/exo_player_control_view.xml new file mode 100644 index 00000000..54b38ad7 --- /dev/null +++ b/android-exoplayer/src/main/res/layout/exo_player_control_view.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +