Changed the execution order of initializePlayerControl method in order to align with player state
This commit is contained in:
parent
1430dc7fea
commit
bd8aa99645
@ -281,11 +281,6 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
if(playerControlView == null) {
|
if(playerControlView == null) {
|
||||||
playerControlView = new PlayerControlView(getContext());
|
playerControlView = new PlayerControlView(getContext());
|
||||||
}
|
}
|
||||||
LayoutParams layoutParams = new LayoutParams(
|
|
||||||
LayoutParams.MATCH_PARENT,
|
|
||||||
LayoutParams.MATCH_PARENT);
|
|
||||||
playerControlView.setLayoutParams(layoutParams);
|
|
||||||
addView(playerControlView, 1, layoutParams);
|
|
||||||
|
|
||||||
//Setting the player for the playerControlView
|
//Setting the player for the playerControlView
|
||||||
playerControlView.setPlayer(player);
|
playerControlView.setPlayer(player);
|
||||||
@ -305,12 +300,24 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
@Override
|
@Override
|
||||||
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
|
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
|
||||||
reLayout(playPauseControlContainer);
|
reLayout(playPauseControlContainer);
|
||||||
|
//Remove this eventListener once its executed. since UI will work fine once after the reLayout is done
|
||||||
player.removeListener(eventListener);
|
player.removeListener(eventListener);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
player.addListener(eventListener);
|
player.addListener(eventListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adding Player control to the frame layout
|
||||||
|
*/
|
||||||
|
private void addPlayerControl() {
|
||||||
|
LayoutParams layoutParams = new LayoutParams(
|
||||||
|
LayoutParams.MATCH_PARENT,
|
||||||
|
LayoutParams.MATCH_PARENT);
|
||||||
|
playerControlView.setLayoutParams(layoutParams);
|
||||||
|
addView(playerControlView, 1, layoutParams);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the layout
|
* Update the layout
|
||||||
*
|
*
|
||||||
@ -369,6 +376,9 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
eventEmitter.loadStart();
|
eventEmitter.loadStart();
|
||||||
loadVideoStarted = true;
|
loadVideoStarted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Initializing the playerControlView
|
||||||
|
initializePlayerControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
|
private MediaSource buildMediaSource(Uri uri, String overrideExtension) {
|
||||||
@ -1135,8 +1145,8 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
*/
|
*/
|
||||||
public void setControls(boolean controls) {
|
public void setControls(boolean controls) {
|
||||||
if(controls && (exoPlayerView != null)) {
|
if(controls && (exoPlayerView != null)) {
|
||||||
//Initialize playerControlView
|
//adding the playerControlView
|
||||||
initializePlayerControl();
|
addPlayerControl();
|
||||||
} else {
|
} else {
|
||||||
if(getChildAt(1) instanceof PlayerControlView && (exoPlayerView != null)){
|
if(getChildAt(1) instanceof PlayerControlView && (exoPlayerView != null)){
|
||||||
removeViewAt(1);
|
removeViewAt(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user