0

Update:
After much research I've asked this question instead. It gets to the core of the problem. Google IMA webview is not showing when used inside react native on android


We are using react-native-video to use the exoplayer on android to show video with adds. The problem is, the exoplayer doesn't show the skip-button when an ad is skippable. To solve this problem we need to know if an ad is skippable and show a custom skipp-button. That's where I'm stuck. I can't get access to this information without changing the sourcecode of the exoplayer ima-extention.

The preferred solution would be to change the ImaAdsLoader**.onAdEvent() to broadcast an event when the add is loaded that exposes the Ad that has been loaded. Then monitor the playback-progress and show/hide a custom skipp-button.

Is there a way to get the information without altering the code of the ima-extention?

 @Override
  public void onAdEvent(AdEvent adEvent) {
    AdEventType adEventType = adEvent.getType();
    boolean isLogAdEvent = adEventType == AdEventType.LOG;
    if (DEBUG || isLogAdEvent) {
      Log.w(TAG, "onAdEvent: " + adEventType);
      if (isLogAdEvent) {
        for (Map.Entry<String, String> entry : adEvent.getAdData().entrySet()) {
          Log.w(TAG, "  " + entry.getKey() + ": " + entry.getValue());
        }
      }
    }
    if (adsManager == null) {
      Log.w(TAG, "Dropping ad event after release: " + adEvent);
      return;
    }
    Ad ad = adEvent.getAd();
    switch (adEvent.getType()) {
      case LOADED:

        //This line is what I need
        eventListener.onAdLoaded(ad);   

        // The ad position is not always accurate when using preloading. See [Internal: b/62613240].
        AdPodInfo adPodInfo = ad.getAdPodInfo();
        int podIndex = adPodInfo.getPodIndex();
        adGroupIndex = podIndex == -1 ? adPlaybackState.adGroupCount - 1 : podIndex;
        int adPosition = adPodInfo.getAdPosition();
        int adCountInAdGroup = adPodInfo.getTotalAds();
        adsManager.start();
        if (DEBUG) {
          Log.d(TAG, "Loaded ad " + adPosition + " of " + adCountInAdGroup + " in ad group "
              + adGroupIndex);
        }
        adPlaybackState.setAdCount(adGroupIndex, adCountInAdGroup);
        updateAdPlaybackState();
        break;
      case CONTENT_PAUSE_REQUESTED:
        // After CONTENT_PAUSE_REQUESTED, IMA will playAd/pauseAd/stopAd to show one or more ads
        // before sending CONTENT_RESUME_REQUESTED.
        imaPausedContent = true;
        pauseContentInternal();
        break;
      case STARTED:
        if (ad.isSkippable()) {
          focusSkipButton();
        }
        break;
      case TAPPED:
        if (eventListener != null) {
          eventListener.onAdTapped();
        }
        break;
      case CLICKED:
        if (eventListener != null) {
          eventListener.onAdClicked();
        }
        break;
      case CONTENT_RESUME_REQUESTED:
        imaPausedContent = false;
        resumeContentInternal();
        break;
      case ALL_ADS_COMPLETED:
        // Do nothing. The ads manager will be released when the source is released.
      default:
        break;
    }
  }
Tom Bevelander
  • 1,686
  • 1
  • 22
  • 31
  • When using the IMA extension the skip button is shown by the IMA library, not by ExoPlayer itself. With native a skip button is shown automatically as an overlay which is a webview provided by IMA. Do you know if a skip button is shown when using plain IMA and react native? If that's not the case an bug should be raised against IMA and this will be solved for the ExoPlayer extension as well. – marcbaechinger Jan 27 '18 at 22:24
  • I'll do some more research and report back. – Tom Bevelander Jan 29 '18 at 16:49
  • Cool. I found this regarding IMA and react native: https://github.com/react-native-community/react-native-video/issues/488 – marcbaechinger Jan 29 '18 at 17:09
  • Thanks Marc. I've done more research and asked a better question. Perhaps you could help? https://stackoverflow.com/questions/48567794/google-ima-webview-is-not-showing-when-used-inside-react-native-on-android – Tom Bevelander Feb 01 '18 at 16:50

0 Answers0