Add an overlay FrameLayout for ad UI

This will be used instead of the current overlay FrameLayout (which apps can
interact with directly).

PiperOrigin-RevId: 233077175
This commit is contained in:
andrewlewis 2019-02-08 17:54:27 +00:00 committed by Andrew Lewis
parent a263fb1631
commit ef139b2e31
3 changed files with 17 additions and 1 deletions

View file

@ -221,6 +221,11 @@ import java.util.List;
* <ul>
* <li>Type: {@link PlayerControlView}
* </ul>
* <li><b>{@code exo_ad_overlay}</b> - A {@link FrameLayout} positioned on top of the player which
* is used to show ad UI (if applicable).
* <ul>
* <li>Type: {@link FrameLayout}
* </ul>
* <li><b>{@code exo_overlay}</b> - A {@link FrameLayout} positioned on top of the player which
* the app can access via {@link #getOverlayFrameLayout()}, provided for convenience.
* <ul>
@ -280,7 +285,8 @@ public class PlayerView extends FrameLayout {
@Nullable private final TextView errorMessageView;
private final PlayerControlView controller;
private final ComponentListener componentListener;
private final FrameLayout overlayFrameLayout;
@Nullable private final FrameLayout adOverlayFrameLayout;
@Nullable private final FrameLayout overlayFrameLayout;
private Player player;
private boolean useController;
@ -317,6 +323,7 @@ public class PlayerView extends FrameLayout {
errorMessageView = null;
controller = null;
componentListener = null;
adOverlayFrameLayout = null;
overlayFrameLayout = null;
ImageView logo = new ImageView(context);
if (Util.SDK_INT >= 23) {
@ -411,6 +418,9 @@ public class PlayerView extends FrameLayout {
surfaceView = null;
}
// Ad overlay frame layout.
adOverlayFrameLayout = findViewById(R.id.exo_ad_overlay);
// Overlay frame layout.
overlayFrameLayout = findViewById(R.id.exo_overlay);
@ -1012,6 +1022,7 @@ public class PlayerView extends FrameLayout {
* @return The overlay {@link FrameLayout}, or {@code null} if the layout has been customized and
* the overlay is not present.
*/
@Nullable
public FrameLayout getOverlayFrameLayout() {
return overlayFrameLayout;
}

View file

@ -52,6 +52,10 @@
</com.google.android.exoplayer2.ui.AspectRatioFrameLayout>
<FrameLayout android:id="@id/exo_ad_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<FrameLayout android:id="@id/exo_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

View file

@ -21,6 +21,7 @@
<item name="exo_artwork" type="id"/>
<item name="exo_controller_placeholder" type="id"/>
<item name="exo_controller" type="id"/>
<item name="exo_ad_overlay" type="id"/>
<item name="exo_overlay" type="id"/>
<item name="exo_play" type="id"/>
<item name="exo_pause" type="id"/>