Commit 8236efe6 by andrewlewis Committed by Oliver Woodman

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
parent d5cbb101
......@@ -141,6 +141,12 @@ import java.util.List;
* <li>Type: {@link View}</li>
* </ul>
* </li>
* <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>
* <li>Type: {@link FrameLayout}</li>
* </ul>
* </li>
* </ul>
* <p>
* 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) {
......
......@@ -44,4 +44,8 @@
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"/>
</FrameLayout>
......@@ -19,6 +19,7 @@
<item name="exo_subtitles" type="id"/>
<item name="exo_artwork" type="id"/>
<item name="exo_controller_placeholder" type="id"/>
<item name="exo_overlay" type="id"/>
<item name="exo_play" type="id"/>
<item name="exo_pause" type="id"/>
<item name="exo_rew" type="id"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment