public interface

AdViewProvider

 androidx.media3.common.AdViewProvider

Subclasses:

PlayerView

Gradle dependencies

compile group: 'androidx.media3', name: 'media3-common', version: '1.0.0-alpha03'

  • groupId: androidx.media3
  • artifactId: media3-common
  • version: 1.0.0-alpha03

Artifact androidx.media3:media3-common:1.0.0-alpha03 it located at Google repository (https://maven.google.com/)

Overview

Provides information about views for the ad playback UI.

Summary

Methods
public java.util.List<AdOverlayInfo>getAdOverlayInfos()

Returns a list of AdOverlayInfo instances describing views that are on top of the ad view group, but that are essential for controlling playback and should be excluded from ad viewability measurements.

public ViewGroupgetAdViewGroup()

Returns the ViewGroup on top of the player that will show any ad UI, or null if playing audio-only ads.

Methods

public ViewGroup getAdViewGroup()

Returns the ViewGroup on top of the player that will show any ad UI, or null if playing audio-only ads. Any views on top of the returned view group must be described by AdOverlayInfos returned by AdViewProvider.getAdOverlayInfos(), for accurate viewability measurement.

public java.util.List<AdOverlayInfo> getAdOverlayInfos()

Returns a list of AdOverlayInfo instances describing views that are on top of the ad view group, but that are essential for controlling playback and should be excluded from ad viewability measurements.

Each view must be either a fully transparent overlay (for capturing touch events), or a small piece of transient UI that is essential to the user experience of playback (such as a button to pause/resume playback or a transient full-screen or cast button). For more information see the documentation for your ads loader.

Source

/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package androidx.media3.common;

import android.view.ViewGroup;
import androidx.annotation.Nullable;
import com.google.common.collect.ImmutableList;
import java.util.List;

/** Provides information about views for the ad playback UI. */
public interface AdViewProvider {

  /**
   * Returns the {@link ViewGroup} on top of the player that will show any ad UI, or {@code null} if
   * playing audio-only ads. Any views on top of the returned view group must be described by {@link
   * AdOverlayInfo AdOverlayInfos} returned by {@link #getAdOverlayInfos()}, for accurate
   * viewability measurement.
   */
  @Nullable
  ViewGroup getAdViewGroup();

  /**
   * Returns a list of {@link AdOverlayInfo} instances describing views that are on top of the ad
   * view group, but that are essential for controlling playback and should be excluded from ad
   * viewability measurements.
   *
   * <p>Each view must be either a fully transparent overlay (for capturing touch events), or a
   * small piece of transient UI that is essential to the user experience of playback (such as a
   * button to pause/resume playback or a transient full-screen or cast button). For more
   * information see the documentation for your ads loader.
   */
  default List<AdOverlayInfo> getAdOverlayInfos() {
    return ImmutableList.of();
  }
}