Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for setControllerVisibilityListener #575

Open
janbolat opened this issue Sep 9, 2019 · 3 comments
Open

Support for setControllerVisibilityListener #575

janbolat opened this issue Sep 9, 2019 · 3 comments

Comments

@janbolat
Copy link

janbolat commented Sep 9, 2019

Hi,
Could you please add a support for com.google.android.exoplayer2.ui.PlayerView.setControllerVisibilityListener so that we can listen to controls visibility?

Thank you

@giladna
Copy link
Contributor

giladna commented Sep 24, 2019

@janbolat I'v opend internal ticket for this FEM-2669

please follow our release when this is added

@janbolat
Copy link
Author

@giladna any news on this?

@giladna
Copy link
Contributor

giladna commented Mar 29, 2020

@janbolat

After looking at it,
Seems that all you have to do is to add this listener on Application level and handle what ever you need
In addition you have the life cycle events to decide if player is visible or not
unless you do it your self and then you know what is the state.

implement -> PlayerControlView.VisibilityListener
  playerFrameLayout = findViewById(R.id.player_view);
            playerFrameLayout.setControllerVisibilityListener(this);
            playerFrameLayout.setErrorMessageProvider(new PlayerErrorMessageProvider());
            playerFrameLayout.requestFocus();
            playerFrameLayout.addView(player.getView());

  @Override
  public void onVisibilityChange(int visibility) {
    debugRootView.setVisibility(visibility);
  }
@Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        log.d("dispatchKeyEvent");

        if (playerFrameLayout != null) {
            // See whether the player view wants to handle media or DPAD keys events.
            return playerFrameLayout.dispatchKeyEvent(event) || super.dispatchKeyEvent(event);
        }
        return false;
    }

could you explain your use case or share a sample app?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants