AVPlayer UITapGestureRecognizer not working

avplayer detect touch
avplayerviewcontroller example
avplayerviewcontroller custom controls
avplayerviewcontroller close button delegate

I have this code for my AVPlayerViewController.

UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAvPlayer)];
[self.avPlayerViewController.view addGestureRecognizer:tap];

but this is not working.. :S, I tried setting

[self.avPlayerViewController.view setUserInteractionEnabled:YES];

still no good..

The only working solution is to use UIGestureRecognizer and implement it's shouldReceiveTouch delegate and check if the av player is touched.. but the issue is, we wan't to capture the "tap release" event.. because if the av player view is just touched, it immediately executes the code and that is not what we wanted...

Please help us with this issue..

Thanks!

Or you can subclass the AVPlayerViewController and use folowwing method to

get the control : -

1.touchBegan 2.touchEnd

Make sure that you set this flag self.avPlayerContr.showsPlaybackControls = false

Hope this works for you.

AVPlayerViewController UITapGestureRecognizer not working in , I know this could be a replicate of this question AVPlayer UITapGestureRecognizer not working However, I still post it because I don't have​  Set showsPlaybackControls to false initially. Add a UITapGestureRecognizer to recognize the initial tap. In the action method for the gesture recognizer, set showsPlaybackControls to true. So far, it would work, but the controls would disappear immediately on that initial tap.

The correct place for gesture handling on an AVPlayerViewController is inside the controller's contentOverlayView .

contentOverlayView is a read-only property of AVPlayerViewController. It's a view that shows up over the video, but under the controller. Just the perfect place for touch handling. You can add subviews or gesture handlers to it at load time.

The following code gives your video controller touch support in two ways, to demonstrate both the gesture recognize and UIButton approaches.

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"mySegue"])
    {
        // Set things up when we're about to go the the video
        AVPlayerViewController *avpvc = segue.destinationViewController;
        AVPlayer *p = nil;
        p = [AVPlayer playerWithURL:[NSURL URLWithString:@"https://my-video"]];
        avpvc.player = p;

        // Method 1: Add a gesture recognizer to the view
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(myAction:)];
        avpvc.contentOverlayView.gestureRecognizers = @[tap];

        // Method 2: Add a button to the view
        UIButton *cov = [UIButton buttonWithType:UIButtonTypeCustom];
        [cov addTarget:self action:@selector(myAction:) forControlEvents:UIControlEventTouchUpInside];
        cov.frame = self.view.bounds;
    }
}

(not really up for writing a Swift version at the moment, sorry. :)

TVOS allowedPressTypes not work wi…, That actually isn't possible to do with the UIGestureRecognizer API: if you want that behavior, you should consider using AVPlayerViewController. The only working solution is to use UIGestureRecognizer and implement it's shouldReceiveTouch delegate and check if the av player is touched.. but the issue is, we wan't to capture the "tap release" event.. because if the av player view is just touched, it immediately executes the code and that is not what we wanted

This should do it. Add the recognizer to the subview of the player instead:

[videoPlayerViewController.view.subviews[0] addGestureRecognizer:tap]

This was a quick fix for complex UI and gestures look into contentOverlayView see TyR answer

play Pause gestureRecognizer stops working afte |Apple , I have a problem where a gestureRecognizer for the play/pause button stops working after playing a video with a AVPlayerViewController on tvOS 10. This. func tapped(_ sender:UITapGestureRecognizer) {; playPause = ! Twilio Client Python not Working in IOS Browser. javascript,python,ios,flask,twilio. Twilio developer evangelist here. Twilio Client uses WebRTC and falls back to Flash in order to make web browsers into phones. Unfortunately Safari on iOS supports neither WebRTC nor Flash so Twilio Client cannot work within any browser on iOS.

As far as my knowledge is concerned what you really want to is

UILongPressGestureRecognizer

Because,

UITapGestureRecognizer

Does not have any release type of event, if u add the

UILongPressGestureRecognizer

to your

avPlayerViewController

Then in

-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
  if ( [gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]] ) {

  }
  return YES;
}

Then you can set the minimum duration of the gesture to have a better feel,

[holdGesture setMinimumPressDuration:0.01]

Then you can implement the method,

- (void)holdAction:(UILongPressGestureRecognizer *)holdRecognizer

Then check the state of the recognizer and perform desired functionality

Swift iOS - Detect Touch Drag Enter UIView from outside UIView, AVPlayerViewController UITapGestureRecognizer not working in ios 11. I know this could be a replicate of this question AVPlayer UITapGestureRecognizer not  @aarthidl:. In my app, I use special TapGestureRecognizer's to a Label an to Images. The Images are "stars" and used for voting (1-5 stars) (included in a own class).

You can add transparent view on avplayerViewController and can add tapgesturerecognizer on that view. hope this will help :)

Overriding a framework gesture in AVPlayerViewController, I'm having a bit of a problem with a UITapGestureRecognizer. I create it this way: self.userInteractionEnabled = YES; UITapGestureRecognizer *tapRecognizer  Overview Dolby Audio and Dolby Atmos. Native support for Dolby Audio™ was introduced in iOS 9.3, back in March 2016. Audio formats like Dolby Digital Plus™ (also known as DD+ or E-AC3) and Dolby Digital (aka DD or AC3) are now supported on hundreds of millions of iOS devices, including both iPhone and iPad, providing essential support for enabling Dolby Audio experiences.

How to detect a double tap gesture, The iOS UITapGestureRecognizer class has a built-in way to detect a double tap on any view. All you need Here's an example: override func 

iOS, Example#. The double tap, like a single tap, also uses the UITapGestureRecognizer . You simply set the numberOfTapsRequired to 2 . Swift override func 

Shobba/AVPlayer-GestureRecognizer-Bug-Test, Contribute to Shobba/AVPlayer-GestureRecognizer-Bug-Test development by creating an which I can play/pause via UITapGestureRecognizer (PlayPause button). The problem starts as soon as I call "play()" on the embedded AVPlayer.

Comments
  • Overriding UIControl methods is a hack. Preferred approach is with contentOverlayView (see my answer).
  • I have a AVPlayerViewController that is responsible for playing a video inside a custom UITableViewCell. The method of adding the gesture recognizer to the contentOverlayView doesn't seem to work. Somehow the touches are being intercepted once the player view gets added to the cell. Any thoughts on what I might be able to do to work around this issue? Thanks!
  • I was trying to get this to work for a week and this is all it took. Beautiful. Thanks man, you really saved me.
  • On iOS 11 this makes the app crash.
  • anyone can confirm is it still crashing on final v11?
  • Uses undocumented SPI. Preferred approach is with contentOverlayView (see my answer).
  • On iOS 12 this makes the app crash.
  • doesn't work...