I'm using a MediaPlayer in a TextureView to play a video in my Android app. When the MediaController is visible, it prevents me from selecting the ImageButtons I have below it in the same view (see image).
When the MediaController is hidden, I can select the buttons. I also tried moving the MediaController very far away from the buttons to see whether they were accidentally overlapping, but I still had the same problem.
How can I ensure that I can still select the ImageButtons even when the MediaController is visible?
Here is my layout file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
android:orientation="vertical"
tools:context=".MediaPreview" >
<FrameLayout
android:id="@+id/media_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom_button_image_preview"
android:layout_alignParentTop="true"
android:background="@color/black"
android:gravity="center" >
<FrameLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black" >
</FrameLayout>
<TextureView
android:id="@+id/s3_video"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:rotation="0"
/>
</FrameLayout>
<ProgressBar
android:id="@+id/media_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<LinearLayout
android:id="@+id/bottom_button_image_preview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/white"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:focusableInTouchMode="true"
android:clickable="true"
android:descendantFocusability="blocksDescendants" >
<ImageButton
android:id="@+id/delete_imagePreview"
android:layout_width="wrap_content"
android:layout_height="@dimen/bottom_button_height"
android:layout_marginRight="1dp"
android:layout_weight="0.3"
android:adjustViewBounds="true"
android:background="@drawable/custom_button_blue"
android:contentDescription="@string/delete_imagePreview"
android:maxHeight="60dp"
android:maxWidth="60dp"
android:scaleType="fitCenter"
android:src="@drawable/ic_action_discard"
android:focusableInTouchMode="true"
android:clickable="true"
android:descendantFocusability="blocksDescendants">
</ImageButton>
<ImageButton
android:id="@+id/okay_imagePreview"
android:layout_width="wrap_content"
android:layout_height="@dimen/bottom_button_height"
android:layout_weight="0.3"
android:adjustViewBounds="true"
android:background="@drawable/custom_button_blue"
android:contentDescription="@string/okay_imagePreview"
android:maxHeight="60dp"
android:maxWidth="60dp"
android:scaleType="fitCenter"
android:src="@drawable/ic_action_accept_white"
android:focusableInTouchMode="true"
android:clickable="true"
android:descendantFocusability="blocksDescendants">
</ImageButton>
</LinearLayout>
Here is how I create the controller:
// set up mediacontroller
videoController = new MediaController(this);
videoControllerExists = true;
videoController.setAnchorView(mediaHolder);
videoController.setPadding(0, 0, 0, bottomButtonHeight);
I then associate it with a mediaPlayer here:
@Override
public void onPrepared(MediaPlayer mp) {
if(isAmazon && mediaURL.length() > 0){
videoController.setMediaPlayer(this);
videoController.setEnabled(true);
videoController.show();
}
}