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

Request: allow PlayerView to be clickable #5433

Closed
AndroidDeveloperLB opened this issue Jan 24, 2019 · 11 comments
Closed

Request: allow PlayerView to be clickable #5433

AndroidDeveloperLB opened this issue Jan 24, 2019 · 11 comments
Assignees
Labels

Comments

@AndroidDeveloperLB
Copy link

This is a tiny request.

I've noticed that if I set an OnClickListener on the PlayerView (even if I add android:clickable="true" android:focusable="true" in the layout file), it doesn't respond to click events.

Please allow the view to be clickable, maybe even touchable...

The only solution for this, is to set the OnClickListener on the container, or a view that's on top of the PlayerView .

@ojw28
Copy link
Contributor

ojw28 commented Jan 24, 2019

I added the following code to the ExoPlayer demo app (in PlayerActivity), and clicks were received and logged fine, except in the case they were specifically handled by one of the view's interactive components (e.g. the seek bar and the playback control buttons):

playerView.setOnClickListener(new OnClickListener() {
   @Override
  public void onClick(View v) {
    Log.e("XXX", "onClick");
  }
});

So I'm not sure there's anything to do here.

@AHuminskyi
Copy link

AHuminskyi commented Jan 27, 2019

Yeah, I also see that this question is opened. So i'm implemented a work around :) I based my playerView under the view (playerContainer) . It will intercept all touch events including onClick()

playerContainer.setOnClickListener { if (videoPlayer.playWhenReady && videoPlayer.playbackState == Player.STATE_READY) { videoPlayer.playWhenReady = false play.visibility = View.VISIBLE } }

@AndroidDeveloperLB
Copy link
Author

@ojw28 To me it doesn't work. Tested on Pixel 2 with Android P.
Check attached project and video to show issue.

ExoPlayerTest.zip

@ojw28
Copy link
Contributor

ojw28 commented Jan 27, 2019

Ah... It looks like this is fixed already in dev-v2, but the fix hasn't been included in any release yet. I think it was fixed in 0a7745b, which changed how PlayerView handles touch events to fix a warning. It likely didn't get cherry-picked into a minor 2.9.x release because we didn't realize it was actually fixing something other than the Android Studio warning.

Leaving this issue open just to track getting the fix cherry-picked into a 2.9.5, if there is one. Else it will be in 2.10.0.

@AndroidDeveloperLB
Copy link
Author

@ojw28 Can you please explain what is the origin of this issue? Why is there even something that changed the default behavior of View being clicked?

@ojw28
Copy link
Contributor

ojw28 commented Jan 27, 2019

Why don't you look in the referenced commit, if you're interested? PlayerView has logic for handling touches because it needs to display the player controls when this happens.

@AndroidDeveloperLB
Copy link
Author

@ojw28 I see. Thank you

@eneim
Copy link
Contributor

eneim commented Jan 29, 2019

Also have this 'issue' before, my workaround is also to wrap it by a FrameLayout ... Really appreciate a 'fix' :D.

@ojw28
Copy link
Contributor

ojw28 commented Jan 30, 2019

Cherry-picked into the 2.9.5 release branch (which isn't released yet, but will be soon).

@ojw28 ojw28 closed this as completed Jan 30, 2019
@ojw28
Copy link
Contributor

ojw28 commented Jan 30, 2019

Release branch commit: e5bf47e

@naimishvinchhi
Copy link

Clickable in version 2.9.5. Thanks!

warren-bank added a commit to warren-bank/Android-RTSP-IPCam-Viewer that referenced this issue Jun 1, 2019
references:
  google/ExoPlayer#5433
  google/ExoPlayer@0a7745b
  https://github.com/google/ExoPlayer/blob/0a7745bc03c93709e178c578a4649eb534e8a9e0/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java#L1031

summary:
* issue #5433: "Request: allow PlayerView to be clickable"
* fix came in commit: 0a7745b
* since the ExoPlayer library is now based on a PR from an older fork,
  this fix is missing
* applying only a minimal patch
@google google locked and limited conversation to collaborators Aug 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants