Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Android JWPlayerFragment cover my custom button


I am trying to add a custom button at the top right of the screen and in the front of JWPlayerFragment. In the portrait mode, the player in the middle of screen, so the custom button display properly. However, in the landscape mode, the player is full screen and the custom button is hidden. Here is my xml:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/Black"
android:fitsSystemWindows="true"
android:keepScreenOn="true">


<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.longtailvideo.jwplayer.JWPlayerFragment"
android:id="@+id/jwPlayerFragment"
tools:layout="@layout/jw_player_fragment_sample_layout"
/>

<ImageView
android:id="@+id/custom_button"
android:layout_width="@dimen/small_image_button_size"
android:layout_height="@dimen/small_image_button_size"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/customButton"/>

</RelativeLayout>

My question is how to show my custom button in landscape mode. Currently it is covered by player view even though I added my custom button in the front of it.

7 Community Answers

George

JW Player Support Agent  
0 rated :

Hi,

Please refer to the documentation here, where we explain what happens when the player goes to fullscreen:
https://developer.jwplayer.com/sdk/android/docs/developer-guide/usage/jwplayer-view/#orientation-changes-and-fullscreen-handling

Binh Nguyen

User  
0 rated :

Hi George,

Thank you for your response.

I downloaded new jw player sample code here https://github.com/jwplayer/jwplayer-sdk-android-demo to make sure everything is fresh.

Followed the documentation by adding setVisibility to my button during onFullscreen() get called, but still nothing changes. The button is visible in portrait mode and hidden in landscape mode. I only change 2 places:

activity_jwplayerview.xml:

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_jwplayerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.longtailvideo.jwplayer.JWPlayerView
android:id="@+id/jwplayer"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>


<Button
android:id="@+id/ok_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="OK"
/>

</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>

And JWPlayerViewExample:

@Override
public void onFullscreen(boolean fullscreen) {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
if (fullscreen) {
findViewById(R.id.ok_button).setVisibility(View.VISIBLE);
actionBar.hide();
} else {
actionBar.show();
}
}

// When going to Fullscreen we want to set fitsSystemWindows="false"
mCoordinatorLayout.setFitsSystemWindows(!fullscreen);
}

Do you have any idea? Please advise.

George

JW Player Support Agent  
0 rated :

view.bringToFront() ?

Binh Nguyen

User  
0 rated :

No, it doesn't work.

George

JW Player Support Agent  
0 rated :

If you have a paid account you can submit a support case through the dashboard. I’d need the following information:

Device’s Android Version:
JW Player SDK for Android version number:
Device make and model where you are experiencing this issue:
Provide step by step instructions on how to reproduce your issue:
JW Player Demo Application Source Code that is also experiencing the issue:

As the last field suggests, please replicate this issue using the JW Player Demo Application and send us a link to a zipped version of the entire Android Studio Project for testing which can be found here:
https://github.com/jwplayer/jwplayer-sdk-android-demo

Binh Nguyen

User  
0 rated :

Finally I can make it works by using JWPlayerView instead of JWPlayerFragment and removing the code below
playerView.setFullscreen(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE, true);
The first argument will set view player in fullscreen mode that causes bringing any custom items to back.

George

JW Player Support Agent  
0 rated :

Sounds very likely

This question has received the maximum number of answers.