PierfrancescoSoffritti / android-youtube-player

YouTube Player library for Android and Chromecast, stable and customizable.
https://pierfrancescosoffritti.github.io/android-youtube-player/
MIT License
3.42k stars 759 forks source link

click listeners do not work #105

Open thesultanster opened 6 years ago

thesultanster commented 6 years ago

The click events are never fired. If I put a transparent view in front of my youtube view, the click event is fired for that transparent view, but then that transparent view steals the click event from the youtube seekbar, play, fullscreen button etc.

Any suggestions?

youTubePlayerView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                log.debug( "youTubePlayerView:MOTIONEVENT");
                // Get motion event type
                switch (event.getAction()) {
                    // This event is when user clicks down
                    case MotionEvent.ACTION_DOWN:
                        log.debug( "youTubePlayerView:ACTION_DOWN");
                        EventBus.getDefault().post(new VideoUIControlEvent("EXPAND_VIDEO"));
                        break;
                }
                return true;
            }

        });
       youTubePlayerView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                log.debug( "youTubePlayerView:setOnClickListener");
            }
        });
PierfrancescoSoffritti commented 6 years ago

Hi, I m going to be traveling for the next couple of days. I ll get back to you when I m home this Sunday :)

dragossusi commented 5 years ago

did you find out how to do this?

PierfrancescoSoffritti commented 5 years ago

I'll double check tomorrow and let you know.

PierfrancescoSoffritti commented 5 years ago

At the moment I don't see any easy way to solve this without removing the click listeners from the UI controller.

ricard-v commented 5 years ago

Could you provide a callback when you capture the click ? That way you would not need to remove the click listeners from the UI controller.

PierfrancescoSoffritti commented 5 years ago

Yeah that would require adding some "non standard" click listener. I'll think about it. Feel free to send a pull request with your idea.

mrkamiali commented 4 years ago

Hi, @PierfrancescoSoffritti is it possible if I override dispatchTouchEvent method in SixteenByNineFrameLayout class. will it be helpful to get touch listener I think so.

PierfrancescoSoffritti commented 4 years ago

Feel free to send a pull request. These days I don't have much time to work on the library.

mrkamiali commented 4 years ago

@PierfrancescoSoffritti I have implemented click listener and sent you a pull request please have look.

463

Raunak-Dutta commented 4 years ago

The click events are never fired. If I put a transparent view in front of my youtube view, the click event is fired for that transparent view, but then that transparent view steals the click event from the youtube seekbar, play, fullscreen button etc.

Any suggestions?

youTubePlayerView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                log.debug( "youTubePlayerView:MOTIONEVENT");
                // Get motion event type
                switch (event.getAction()) {
                    // This event is when user clicks down
                    case MotionEvent.ACTION_DOWN:
                        log.debug( "youTubePlayerView:ACTION_DOWN");
                        EventBus.getDefault().post(new VideoUIControlEvent("EXPAND_VIDEO"));
                        break;
                }
                return true;
            }

        });
      youTubePlayerView.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               log.debug( "youTubePlayerView:setOnClickListener");
           }
       });

Seems like this was never added, how do I add a transparent view tho?

PierfrancescoSoffritti commented 4 years ago

You can add a custom UI and do what you want with it. The default UI doesn't support this yet.