From 8236efe6a544fc81b151fb42d7adf140e93902fc Mon Sep 17 00:00:00 2001 From: andrewlewis Date: Wed, 9 Nov 2016 00:59:00 -0800 Subject: [PATCH] Provide an overlay FrameLayout in SimpleExoPlayerView. This can be used by the app for showing arbitrary UI on top of the player (for example, UI elements associated with an ad). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=138610733 --- .../exoplayer2/ui/SimpleExoPlayerView.java | 25 +++++++++++++++++-- .../res/layout/exo_simple_player_view.xml | 4 +++ library/src/main/res/values/ids.xml | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/com/google/android/exoplayer2/ui/SimpleExoPlayerView.java b/library/src/main/java/com/google/android/exoplayer2/ui/SimpleExoPlayerView.java index 3d99890b6b..5acb3bfb45 100644 --- a/library/src/main/java/com/google/android/exoplayer2/ui/SimpleExoPlayerView.java +++ b/library/src/main/java/com/google/android/exoplayer2/ui/SimpleExoPlayerView.java @@ -141,6 +141,12 @@ import java.util.List; *
  • Type: {@link View}
  • * * + *
  • {@code exo_overlay} - A {@link FrameLayout} positioned on top of the player which + * the app can access via {@link #getOverlayFrameLayout()}, provided for convenience. + * + *
  • * *

    * All child views are optional and so can be omitted if not required, however where defined they @@ -167,6 +173,7 @@ public final class SimpleExoPlayerView extends FrameLayout { private final SubtitleView subtitleView; private final PlaybackControlView controller; private final ComponentListener componentListener; + private final FrameLayout overlayFrameLayout; private SimpleExoPlayer player; private boolean useController; @@ -231,6 +238,9 @@ public final class SimpleExoPlayerView extends FrameLayout { surfaceView = null; } + // Overlay frame layout. + overlayFrameLayout = (FrameLayout) findViewById(R.id.exo_overlay); + // Artwork view. artworkView = (ImageView) findViewById(R.id.exo_artwork); this.useArtwork = useArtwork && artworkView != null; @@ -421,15 +431,26 @@ public final class SimpleExoPlayerView extends FrameLayout { } /** - * Get the view onto which video is rendered. This is either a {@link SurfaceView} (default) + * Gets the view onto which video is rendered. This is either a {@link SurfaceView} (default) * or a {@link TextureView} if the {@code use_texture_view} view attribute has been set to true. * - * @return either a {@link SurfaceView} or a {@link TextureView}. + * @return Either a {@link SurfaceView} or a {@link TextureView}. */ public View getVideoSurfaceView() { return surfaceView; } + /** + * Gets the overlay {@link FrameLayout}, which can be populated with UI elements to show on top of + * the player. + * + * @return The overlay {@link FrameLayout}, or {@code null} if the layout has been customized and + * the overlay is not present. + */ + public FrameLayout getOverlayFrameLayout() { + return overlayFrameLayout; + } + @Override public boolean onTouchEvent(MotionEvent ev) { if (!useController || player == null || ev.getActionMasked() != MotionEvent.ACTION_DOWN) { diff --git a/library/src/main/res/layout/exo_simple_player_view.xml b/library/src/main/res/layout/exo_simple_player_view.xml index c4f34ef285..b21b0d2bd6 100644 --- a/library/src/main/res/layout/exo_simple_player_view.xml +++ b/library/src/main/res/layout/exo_simple_player_view.xml @@ -44,4 +44,8 @@ android:layout_width="match_parent" android:layout_height="match_parent"/> + + diff --git a/library/src/main/res/values/ids.xml b/library/src/main/res/values/ids.xml index 5c533ef8d4..f55c8f6945 100644 --- a/library/src/main/res/values/ids.xml +++ b/library/src/main/res/values/ids.xml @@ -19,6 +19,7 @@ +