How to add Gesture on Ad Player

341 views
Skip to first unread message

Wekij Liwrojsup

unread,
Sep 7, 2014, 7:35:54 AM9/7/14
to ima...@googlegroups.com
Hello,

   I want to add Gesture to Ad Player how can I do?

Wekij

Shawn Busolits (IMA SDK Team)

unread,
Sep 8, 2014, 10:05:18 AM9/8/14
to ima...@googlegroups.com
Hi Wekij,

Which SDK are you working with?

Thanks,
Shawn Busolits
IMA SDK Team

Wekij Liwrojsup

unread,
Sep 8, 2014, 9:46:24 PM9/8/14
to ima...@googlegroups.com
Hi Shawn,

    Google IMA for IOS

Wekij

Shawn Busolits (IMA SDK Team)

unread,
Sep 9, 2014, 10:35:00 AM9/9/14
to ima...@googlegroups.com
Hi Wekij,

If you're setting up your player like we do in the sample app, you should be able to add a gesture recognizer on your video view and still recognize gestures while ads are playing. For example, I added the following to the bottom of viewDidLoad in the sample:

UILongPressGestureRecognizer *lpr =
    [[UILongPressGestureRecognizer alloc]
        initWithTarget:self action:@selector(displayGestureForLongPressRecognizer:)];
[self.videoView addGestureRecognizer:lpr];

And then added the following to the bottom of the ViewController:

- (IBAction)displayGestureForLongPressRecognizer:(UILongPressGestureRecognizer *)recognizer {
  [self logMessage:@"LONG PRESS"];
}

If I long pressed on the video while the video or an ad was playing, I got "LONG PRESS" logs in the console. I followed the guide here for adding the gesture recognizer. If you have any other questions let me know!

Thanks,
Shawn Busolits
IMA SDK Team
Message has been deleted

Wekij Liwrojsup

unread,
Sep 10, 2014, 1:40:49 AM9/10/14
to ima...@googlegroups.com
Hi Shawn,

    I apologise for unclear question. I can swipe gesture on video player and it works when it play video but the gesture does not work when play ads. 

Thanks,
Wekij

Shawn Busolits (IMA SDK Team)

unread,
Sep 10, 2014, 10:39:17 AM9/10/14
to ima...@googlegroups.com
Hi Wekij,

Which version of the SDK are you working with? We modified our ad rendering a bit for beta 7, so if you're working with an older version that may be causing the issue.

If you are on our latest version, could you send me the snippet of code that sets up your gesture recognizer?

Thanks,
Shawn Busolits
IMA SDK Team
Message has been deleted

Wekij Liwrojsup

unread,
Sep 10, 2014, 11:05:09 PM9/10/14
to ima...@googlegroups.com
Hi Shawn,

   I already used new version (Using GoogleAds-IMA-iOS-SDK (3.0.beta.7), Using GoogleMediaFramework (1.0.0)) and I try you code before and I can see "LONG PRESS" but I think it cannot use swipe because it have an event for touch.
PS. I can swipe when I touch player control bar.

  My Code:
   
    GMFPlayerViewController *videoPlayerViewController  = [[GMFPlayerViewController allocinit];
    ....
    ...

    UISwipeGestureRecognizer *swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(minimizeView:)];

    swipeDown.direction = UISwipeGestureRecognizerDirectionDown;

    [self.videoPlayerViewController.view addGestureRecognizer:swipeDown];

Thanks,

Wekij

Shawn Busolits (IMA SDK Team)

unread,
Sep 11, 2014, 10:21:58 AM9/11/14
to ima...@googlegroups.com
Hi Wekij,

Sorry for the confusion - I didn't realize you were using the Google Media Framework. That product has its own support forum here - the folks on that forum should be able to help you much better that I can.

Thanks,
Shawn Busolits
IMA SDK Team

Wekij Liwrojsup

unread,
Sep 11, 2014, 10:32:03 PM9/11/14
to ima...@googlegroups.com
Hi Shawn,

   I try to use IMA Tutorial and I add Code

- (void)viewDidLoad {

   ...

    UITapGestureRecognizer *tapped = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tab:)];

    tapped.numberOfTapsRequired = 1;

    [self.containerView addGestureRecognizer:tapped];  //containerView is My UIView

    [self.adDisplayContainer.adContainer addGestureRecognizer:tapped];

}

-(void)tab:(id)sender{

     NSLog(@"TAB");

}

   It doesn't write Log "TAB". 

Thanks,

Wekij

Shawn Busolits (IMA SDK Team)

unread,
Sep 12, 2014, 10:38:26 AM9/12/14
to ima...@googlegroups.com
Ah, OK, I think I see the issue. I had not been testing with the tap recognizer (I was using long press). It looks like the issue is that the ad container is already listening for tap, and it's stealing the tap from your listener. I'll work with the rest of the team to see what we can do to resolve this issue. As soon as I have more info I'll let you know.

Thanks,
Shawn Busolits
IMA SDK Team

Wekij Liwrojsup

unread,
Sep 13, 2014, 6:03:47 AM9/13/14
to ima...@googlegroups.com
Hi Shawn,

     Thank you so much Shawn. 

Wekij

Wekij Liwrojsup

unread,
Oct 1, 2014, 10:36:48 PM10/1/14
to ima...@googlegroups.com
Hi Shawn,

    How is going? How can you and your team solve this issue? I'm waiting for your response.

Thanks you, 
Wekij
Message has been deleted

Shawn Busolits (IMA SDK Team)

unread,
Oct 2, 2014, 2:28:07 PM10/2/14
to ima...@googlegroups.com
Hi Wekij,

We're still looking at this one. The plan currently is to add a "tap" event to the SDK that you can listen for. As soon as we have something available I'll let you know.

Thanks,
Shawn Busolits
IMA SDK Team

Wekij Liwrojsup

unread,
Oct 2, 2014, 9:09:00 PM10/2/14
to ima...@googlegroups.com
Hi Shawn,

    Thank you all.

Wekij

Michael Len

unread,
Oct 29, 2014, 2:22:57 PM10/29/14
to ima...@googlegroups.com
Hey Shawn,

Is there any way you can passing-through any tap events that you dont use?  For example, if you're using 

- (BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch

you can return false, and the tap will pass through to the rest of the view hierarchy.  Has this been discussed, or is this a non-option?

Shawn Busolits (IMA SDK Team)

unread,
Oct 30, 2014, 1:56:59 PM10/30/14
to ima...@googlegroups.com
Hi Michael,

Thanks for the tip, that is one of the solutions we're looking into. We still need to test extensively to make sure that this won't interfere with clickthrough, skip button, etc. As soon as we have a working solution available we'll let you know.

Thanks,
Shawn Busolits
IMA SDK Team

Michael Len

unread,
Nov 14, 2014, 2:33:17 AM11/14/14
to ima...@googlegroups.com
Hey Shawn,

Do you have any update on when we could see a fix?

Thanks,
Mike

Shawn Busolits (IMA SDK Team)

unread,
Nov 14, 2014, 10:53:29 AM11/14/14
to ima...@googlegroups.com
Hi Michael,

The solution we've come up with is to have the ad container throw a TAPPED event which you can catch and handle. This feature is code-complete and going through testing now. We're hoping to have a release out including this feature in the next few weeks.

Thanks,
Shawn Busolits
IMA SDK Team

Michael Len

unread,
Nov 14, 2014, 4:16:22 PM11/14/14
to ima...@googlegroups.com
so no luck on passing the touches through the responder chain?  I'm not sure how your code works, but if you're not using the touch event, it doesn't seem right to swallow the event.

For example, does IMA use touchesBegan:withEvent:? If so, IMA should be calling super to bubble the event down the view hierarchy.


The same thing goes for the gestureRecognizer above. However, since we use touchesBegan,  i'm assuming IMA is using it as well and not propagating the message. Can you provide a little insight around the reasoning for this decision?

Thanks,
Mike

Shawn Busolits (IMA SDK Team)

unread,
Nov 17, 2014, 5:42:28 PM11/17/14
to ima...@googlegroups.com
Hey Michael,

That's actually the issue - we're not specifically listening for any gestures on our ad container. Our ad container is using a WebView to display the ad, so all the touch listeners are abstracted out by that WebView. It looks like the WebView is not passing the touches through the view hierarchy. Once the new event is released you should be able to use it the same way you would use a gesture listener on the view itself.

Thanks,
Shawn Busolits
IMA SDK Team

Shawn Busolits (IMA SDK Team)

unread,
Dec 29, 2014, 11:45:38 AM12/29/14
to ima...@googlegroups.com
Hi all,

Our most recent release adds the TAPPED event which will be fired when the user taps on any non-clickable part of an ad. You should be able to use this to get the functionality that was missing previously. If you have any questions let us know!

Thanks,
Shawn Busolits
IMA SDK Team

何大树

unread,
Mar 11, 2015, 5:41:39 AM3/11/15
to ima...@googlegroups.com
Hi  IMA SDK Team
I want to add UITapGestureRecognizer to Ad Player,But I  Cannot  Tap Ad Player. why?

- (void)createAdDisplayContainer {

    self.adDisplayContainer = [[IMAAdDisplayContainer alloc] initWithAdContainer:self.playerView companionSlots:nil];

    UITapGestureRecognizer * hiddenTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hiddenOrShowNavigationBarr)];

    self.adDisplayContainer.adContainer.userInteractionEnabled = YES;

    [self.adDisplayContainer.adContainer addGestureRecognizer:hiddenTap];

Shawn Busolits (IMA SDK Team)

unread,
Mar 11, 2015, 1:26:28 PM3/11/15
to ima...@googlegroups.com
Hi there,

As discussed above in this thread, you cannot listen for taps on the ad container because the SDK is already listening for those taps and they are not being passed on. If you want to listen for that interaction you should use the TAPPED event mentioned above.

Thanks,
Shawn Busolits
IMA SDK Team
Reply all
Reply to author
Forward
0 new messages