Fix for play and pause button UI issue
This commit is contained in:
parent
c156550518
commit
1430dc7fea
@ -98,6 +98,8 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
|
|
||||||
private final VideoEventEmitter eventEmitter;
|
private final VideoEventEmitter eventEmitter;
|
||||||
private PlayerControlView playerControlView;
|
private PlayerControlView playerControlView;
|
||||||
|
private View playPauseControlContainer;
|
||||||
|
private Player.EventListener eventListener;
|
||||||
|
|
||||||
private Handler mainHandler;
|
private Handler mainHandler;
|
||||||
private ExoPlayerView exoPlayerView;
|
private ExoPlayerView exoPlayerView;
|
||||||
@ -264,6 +266,7 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
* Toggling the visibility of the player control view
|
* Toggling the visibility of the player control view
|
||||||
*/
|
*/
|
||||||
private void togglePlayerControlVisibility() {
|
private void togglePlayerControlVisibility() {
|
||||||
|
reLayout(playerControlView);
|
||||||
if(playerControlView.isVisible()) {
|
if(playerControlView.isVisible()) {
|
||||||
playerControlView.hide();
|
playerControlView.hide();
|
||||||
} else {
|
} else {
|
||||||
@ -287,6 +290,7 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
//Setting the player for the playerControlView
|
//Setting the player for the playerControlView
|
||||||
playerControlView.setPlayer(player);
|
playerControlView.setPlayer(player);
|
||||||
playerControlView.show();
|
playerControlView.show();
|
||||||
|
playPauseControlContainer = playerControlView.findViewById(R.id.exo_play_pause_container);
|
||||||
|
|
||||||
//Invoking onClick event for exoplayerView
|
//Invoking onClick event for exoplayerView
|
||||||
exoPlayerView.setOnClickListener(new OnClickListener() {
|
exoPlayerView.setOnClickListener(new OnClickListener() {
|
||||||
@ -295,6 +299,29 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
togglePlayerControlVisibility();
|
togglePlayerControlVisibility();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Invoking onPlayerStateChanged event for Player
|
||||||
|
eventListener = new Player.EventListener() {
|
||||||
|
@Override
|
||||||
|
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
|
||||||
|
reLayout(playPauseControlContainer);
|
||||||
|
player.removeListener(eventListener);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
player.addListener(eventListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the layout
|
||||||
|
*
|
||||||
|
* This is a workaround for the open bug in react-native: https://github.com/facebook/react-native/issues/17968
|
||||||
|
* @param view view needs to update layout
|
||||||
|
*/
|
||||||
|
private void reLayout(View view) {
|
||||||
|
if(view == null) return;
|
||||||
|
view.measure(MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.EXACTLY),
|
||||||
|
MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.EXACTLY));
|
||||||
|
view.layout(view.getLeft(), view.getTop(), view.getMeasuredWidth(), view.getMeasuredHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializePlayer() {
|
private void initializePlayer() {
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
<ImageButton android:id="@id/exo_rew"
|
<ImageButton android:id="@id/exo_rew"
|
||||||
style="@style/ExoMediaButton.Rewind"/>
|
style="@style/ExoMediaButton.Rewind"/>
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
android:id="@+id/exo_play_pause_container"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center">
|
android:layout_gravity="center">
|
||||||
|
Loading…
Reference in New Issue
Block a user