3

I have a MPMoviePlayerViewController and I put a UIView on top of it to recognise single tap then I can show a control panel for the video, and double tap should zoom in/out the video play, so I set numberOfTapsRequired=1 for the gesture recogniser, but when I do a double-tap, the video is not zoom but the control panel is displayed and then disappeared as if there were two single taps.

is there anyway to solve it?

Thanks!

hzxu
  • 5,753
  • 11
  • 60
  • 95
  • this may help http://stackoverflow.com/questions/9008975/how-to-tap-to-zoom-and-double-tap-to-zoom-out-with-uiscrollview/9009554#9009554 – GWed Feb 17 '14 at 16:13

1 Answers1

7

Yes. [UIGestureRecognizer requireGestureRecognierToFail:] is for exactly this purpose. Set your single tap gesture recognizer to require the double-tap gesture recognizer to fail. If it doesn't fail, then the zoom happens. If it does fail (i.e. you have only tapped once instead of twice) then your control panel will show.

  • So do I add the double tap recognizer to the view as well? If I do, it will recognize double tap, which then will not be passed to underlying video play view? Also, I want to emphasise that I have another UIView on top of video player's view, otherwise I cannot add the recognizer to MPMoviePlayerViewController.view(or can I?) Thanks! – hzxu Sep 08 '11 at 00:47
  • Yes, you add the double tap to the view as well. The way I got around not being able to add properties to the `MPMoviePlayerViewController` was creating my own `AVPlayer` movie player based on [NGMoviePlayer](https://bitbucket.org/brentsimmons/ngmovieplayer). You may not want to go for that somewhat extreme route though (I was doing it for ad support and other things). –  Sep 08 '11 at 00:51
  • I tried it, now "tap-tap" will not make the control panel to appear and disappear, but the movie play is still not zoomed, so how to pass the double tap to the movie player? Thanks! – hzxu Sep 08 '11 at 00:52
  • To do the zoom, make the double-tap call a function which toggles the [`scalingMode`](http://developer.apple.com/library/ios/documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/Reference/Reference.html#//apple_ref/occ/instp/MPMoviePlayerController/scalingMode) of the `MPMoviePlayerController` object inside `MPMoviePlayerViewController` between `AspectFit` (zoomed out) and `AspectFill` (zoomed in). I stress that you should be investigating this documentation yourself first though, rather than asking people on here first. If the documentation doesn't answer your question, then ask. –  Sep 08 '11 at 01:16