diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlaybackControlView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlaybackControlView.java index 7659dff9c6..fefbb0797a 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlaybackControlView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlaybackControlView.java @@ -42,127 +42,118 @@ import java.util.Locale; /** * A view for controlling {@link Player} instances. - *

- * A PlaybackControlView can be customized by setting attributes (or calling corresponding methods), - * overriding the view's layout file or by specifying a custom view layout file, as outlined below. + * + *

A PlaybackControlView can be customized by setting attributes (or calling corresponding + * methods), overriding the view's layout file or by specifying a custom view layout file, as + * outlined below. * *

Attributes

+ * * The following attributes can be set on a PlaybackControlView when used in a layout XML file: + * *

+ * *

* *

Overriding the layout file

+ * * To customize the layout of PlaybackControlView throughout your app, or just for certain * configurations, you can define {@code exo_playback_control_view.xml} layout files in your * application {@code res/layout*} directories. These layouts will override the one provided by the * ExoPlayer library, and will be inflated for use by PlaybackControlView. The view identifies and * binds its children by looking for the following ids: + * *

+ * *

- *

- * All child views are optional and so can be omitted if not required, however where defined they + * + *

All child views are optional and so can be omitted if not required, however where defined they * must be of the expected type. * *

Specifying a custom layout file

+ * * Defining your own {@code exo_playback_control_view.xml} is useful to customize the layout of * PlaybackControlView throughout your application. It's also possible to customize the layout for a * single instance in a layout file. This is achieved by setting the {@code controller_layout_id} @@ -175,15 +166,11 @@ public class PlaybackControlView extends FrameLayout { ExoPlayerLibraryInfo.registerModule("goog.exo.ui"); } - /** - * @deprecated Use {@link com.google.android.exoplayer2.ControlDispatcher}. - */ + /** @deprecated Use {@link com.google.android.exoplayer2.ControlDispatcher}. */ @Deprecated public interface ControlDispatcher extends com.google.android.exoplayer2.ControlDispatcher {} - /** - * Listener to be notified about changes of the visibility of the UI control. - */ + /** Listener to be notified about changes of the visibility of the UI control. */ public interface VisibilityListener { /** @@ -192,38 +179,25 @@ public class PlaybackControlView extends FrameLayout { * @param visibility The new visibility. Either {@link View#VISIBLE} or {@link View#GONE}. */ void onVisibilityChange(int visibility); - } private static final class DefaultControlDispatcher extends com.google.android.exoplayer2.DefaultControlDispatcher implements ControlDispatcher {} - /** - * @deprecated Use {@link com.google.android.exoplayer2.DefaultControlDispatcher}. - */ + /** @deprecated Use {@link com.google.android.exoplayer2.DefaultControlDispatcher}. */ @Deprecated public static final ControlDispatcher DEFAULT_CONTROL_DISPATCHER = new DefaultControlDispatcher(); - /** - * The default fast forward increment, in milliseconds. - */ + /** The default fast forward increment, in milliseconds. */ public static final int DEFAULT_FAST_FORWARD_MS = 15000; - /** - * The default rewind increment, in milliseconds. - */ + /** The default rewind increment, in milliseconds. */ public static final int DEFAULT_REWIND_MS = 5000; - /** - * The default show timeout, in milliseconds. - */ + /** The default show timeout, in milliseconds. */ public static final int DEFAULT_SHOW_TIMEOUT_MS = 5000; - /** - * The default repeat toggle modes. - */ + /** The default repeat toggle modes. */ public static final @RepeatModeUtil.RepeatToggleModes int DEFAULT_REPEAT_TOGGLE_MODES = RepeatModeUtil.REPEAT_TOGGLE_MODE_NONE; - /** - * The maximum number of windows that can be shown in a multi-window time bar. - */ + /** The maximum number of windows that can be shown in a multi-window time bar. */ public static final int MAX_WINDOWS_FOR_MULTI_WINDOW_TIME_BAR = 100; private static final long MAX_POSITION_FOR_SEEK_TO_PREVIOUS = 3000; @@ -271,19 +245,21 @@ public class PlaybackControlView extends FrameLayout { private long[] extraAdGroupTimesMs; private boolean[] extraPlayedAdGroups; - private final Runnable updateProgressAction = new Runnable() { - @Override - public void run() { - updateProgress(); - } - }; + private final Runnable updateProgressAction = + new Runnable() { + @Override + public void run() { + updateProgress(); + } + }; - private final Runnable hideAction = new Runnable() { - @Override - public void run() { - hide(); - } - }; + private final Runnable hideAction = + new Runnable() { + @Override + public void run() { + hide(); + } + }; public PlaybackControlView(Context context) { this(context, null); @@ -297,8 +273,8 @@ public class PlaybackControlView extends FrameLayout { this(context, attrs, defStyleAttr, attrs); } - public PlaybackControlView(Context context, AttributeSet attrs, int defStyleAttr, - AttributeSet playbackAttrs) { + public PlaybackControlView( + Context context, AttributeSet attrs, int defStyleAttr, AttributeSet playbackAttrs) { super(context, attrs, defStyleAttr); int controllerLayoutId = R.layout.exo_playback_control_view; rewindMs = DEFAULT_REWIND_MS; @@ -307,18 +283,21 @@ public class PlaybackControlView extends FrameLayout { repeatToggleModes = DEFAULT_REPEAT_TOGGLE_MODES; showShuffleButton = false; if (playbackAttrs != null) { - TypedArray a = context.getTheme().obtainStyledAttributes(playbackAttrs, - R.styleable.PlaybackControlView, 0, 0); + TypedArray a = + context + .getTheme() + .obtainStyledAttributes(playbackAttrs, R.styleable.PlaybackControlView, 0, 0); try { rewindMs = a.getInt(R.styleable.PlaybackControlView_rewind_increment, rewindMs); - fastForwardMs = a.getInt(R.styleable.PlaybackControlView_fastforward_increment, - fastForwardMs); + fastForwardMs = + a.getInt(R.styleable.PlaybackControlView_fastforward_increment, fastForwardMs); showTimeoutMs = a.getInt(R.styleable.PlaybackControlView_show_timeout, showTimeoutMs); - controllerLayoutId = a.getResourceId(R.styleable.PlaybackControlView_controller_layout_id, - controllerLayoutId); + controllerLayoutId = + a.getResourceId( + R.styleable.PlaybackControlView_controller_layout_id, controllerLayoutId); repeatToggleModes = getRepeatToggleModes(a, repeatToggleModes); - showShuffleButton = a.getBoolean(R.styleable.PlaybackControlView_show_shuffle_button, - showShuffleButton); + showShuffleButton = + a.getBoolean(R.styleable.PlaybackControlView_show_shuffle_button, showShuffleButton); } finally { a.recycle(); } @@ -379,17 +358,17 @@ public class PlaybackControlView extends FrameLayout { repeatOffButtonDrawable = resources.getDrawable(R.drawable.exo_controls_repeat_off); repeatOneButtonDrawable = resources.getDrawable(R.drawable.exo_controls_repeat_one); repeatAllButtonDrawable = resources.getDrawable(R.drawable.exo_controls_repeat_all); - repeatOffButtonContentDescription = resources.getString( - R.string.exo_controls_repeat_off_description); - repeatOneButtonContentDescription = resources.getString( - R.string.exo_controls_repeat_one_description); - repeatAllButtonContentDescription = resources.getString( - R.string.exo_controls_repeat_all_description); + repeatOffButtonContentDescription = + resources.getString(R.string.exo_controls_repeat_off_description); + repeatOneButtonContentDescription = + resources.getString(R.string.exo_controls_repeat_one_description); + repeatAllButtonContentDescription = + resources.getString(R.string.exo_controls_repeat_all_description); } @SuppressWarnings("ResourceType") - private static @RepeatModeUtil.RepeatToggleModes int getRepeatToggleModes(TypedArray a, - @RepeatModeUtil.RepeatToggleModes int repeatToggleModes) { + private static @RepeatModeUtil.RepeatToggleModes int getRepeatToggleModes( + TypedArray a, @RepeatModeUtil.RepeatToggleModes int repeatToggleModes) { return a.getInt(R.styleable.PlaybackControlView_repeat_toggle_modes, repeatToggleModes); } @@ -422,9 +401,9 @@ public class PlaybackControlView extends FrameLayout { /** * Sets whether the time bar should show all windows, as opposed to just the current one. If the - * timeline has a period with unknown duration or more than - * {@link #MAX_WINDOWS_FOR_MULTI_WINDOW_TIME_BAR} windows the time bar will fall back to showing a - * single window. + * timeline has a period with unknown duration or more than {@link + * #MAX_WINDOWS_FOR_MULTI_WINDOW_TIME_BAR} windows the time bar will fall back to showing a single + * window. * * @param showMultiWindowTimeBar Whether the time bar should show all windows. */ @@ -443,8 +422,8 @@ public class PlaybackControlView extends FrameLayout { * @param extraPlayedAdGroups Whether each ad has been played, or {@code null} to show no extra ad * markers. */ - public void setExtraAdGroupMarkers(@Nullable long[] extraAdGroupTimesMs, - @Nullable boolean[] extraPlayedAdGroups) { + public void setExtraAdGroupMarkers( + @Nullable long[] extraAdGroupTimesMs, @Nullable boolean[] extraPlayedAdGroups) { if (extraAdGroupTimesMs == null) { this.extraAdGroupTimesMs = new long[0]; this.extraPlayedAdGroups = new boolean[0]; @@ -473,8 +452,10 @@ public class PlaybackControlView extends FrameLayout { */ public void setControlDispatcher( @Nullable com.google.android.exoplayer2.ControlDispatcher controlDispatcher) { - this.controlDispatcher = controlDispatcher == null - ? new com.google.android.exoplayer2.DefaultControlDispatcher() : controlDispatcher; + this.controlDispatcher = + controlDispatcher == null + ? new com.google.android.exoplayer2.DefaultControlDispatcher() + : controlDispatcher; } /** @@ -556,9 +537,7 @@ public class PlaybackControlView extends FrameLayout { } } - /** - * Returns whether the shuffle button is shown. - */ + /** Returns whether the shuffle button is shown. */ public boolean getShowShuffleButton() { return showShuffleButton; } @@ -590,9 +569,7 @@ public class PlaybackControlView extends FrameLayout { hideAfterTimeout(); } - /** - * Hides the controller. - */ + /** Hides the controller. */ public void hide() { if (isVisible()) { setVisibility(GONE); @@ -605,9 +582,7 @@ public class PlaybackControlView extends FrameLayout { } } - /** - * Returns whether the controller is currently visible. - */ + /** Returns whether the controller is currently visible. */ public boolean isVisible() { return getVisibility() == VISIBLE; } @@ -664,8 +639,8 @@ public class PlaybackControlView extends FrameLayout { int windowIndex = player.getCurrentWindowIndex(); timeline.getWindow(windowIndex, window); isSeekable = window.isSeekable; - enablePrevious = isSeekable || !window.isDynamic - || player.getPreviousWindowIndex() != C.INDEX_UNSET; + enablePrevious = + isSeekable || !window.isDynamic || player.getPreviousWindowIndex() != C.INDEX_UNSET; enableNext = window.isDynamic || player.getNextWindowIndex() != C.INDEX_UNSET; } setButtonEnabled(enablePrevious, previousButton); @@ -728,8 +703,8 @@ public class PlaybackControlView extends FrameLayout { if (player == null) { return; } - multiWindowTimeBar = showMultiWindowTimeBar - && canShowMultiWindowTimeBar(player.getCurrentTimeline(), window); + multiWindowTimeBar = + showMultiWindowTimeBar && canShowMultiWindowTimeBar(player.getCurrentTimeline(), window); } private void updateProgress() { @@ -836,8 +811,8 @@ public class PlaybackControlView extends FrameLayout { if (mediaTimeDelayMs < (mediaTimeUpdatePeriodMs / 5)) { mediaTimeDelayMs += mediaTimeUpdatePeriodMs; } - delayMs = playbackSpeed == 1 ? mediaTimeDelayMs - : (long) (mediaTimeDelayMs / playbackSpeed); + delayMs = + playbackSpeed == 1 ? mediaTimeDelayMs : (long) (mediaTimeDelayMs / playbackSpeed); } else { delayMs = 200; } @@ -876,7 +851,7 @@ public class PlaybackControlView extends FrameLayout { int previousWindowIndex = player.getPreviousWindowIndex(); if (previousWindowIndex != C.INDEX_UNSET && (player.getCurrentPosition() <= MAX_POSITION_FOR_SEEK_TO_PREVIOUS - || (window.isDynamic && !window.isSeekable))) { + || (window.isDynamic && !window.isSeekable))) { seekTo(previousWindowIndex, C.TIME_UNSET); } else { seekTo(0); @@ -1054,8 +1029,8 @@ public class PlaybackControlView extends FrameLayout { return true; } - private final class ComponentListener extends Player.DefaultEventListener implements - TimeBar.OnScrubListener, OnClickListener { + private final class ComponentListener extends Player.DefaultEventListener + implements TimeBar.OnScrubListener, OnClickListener { @Override public void onScrubStart(TimeBar timeBar, long position) { @@ -1104,8 +1079,8 @@ public class PlaybackControlView extends FrameLayout { } @Override - public void onTimelineChanged(Timeline timeline, Object manifest, - @Player.TimelineChangeReason int reason) { + public void onTimelineChanged( + Timeline timeline, Object manifest, @Player.TimelineChangeReason int reason) { updateNavigation(); updateTimeBarMode(); updateProgress(); @@ -1127,15 +1102,13 @@ public class PlaybackControlView extends FrameLayout { } else if (pauseButton == view) { controlDispatcher.dispatchSetPlayWhenReady(player, false); } else if (repeatToggleButton == view) { - controlDispatcher.dispatchSetRepeatMode(player, RepeatModeUtil.getNextRepeatMode( - player.getRepeatMode(), repeatToggleModes)); + controlDispatcher.dispatchSetRepeatMode( + player, RepeatModeUtil.getNextRepeatMode(player.getRepeatMode(), repeatToggleModes)); } else if (shuffleButton == view) { controlDispatcher.dispatchSetShuffleModeEnabled(player, !player.getShuffleModeEnabled()); } } hideAfterTimeout(); } - } - } diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/SimpleExoPlayerView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/SimpleExoPlayerView.java index c5a4bc8086..def8925ec3 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/SimpleExoPlayerView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/SimpleExoPlayerView.java @@ -268,26 +268,26 @@ public final class SimpleExoPlayerView extends FrameLayout { boolean controllerAutoShow = true; boolean controllerHideDuringAds = true; if (attrs != null) { - TypedArray a = context.getTheme().obtainStyledAttributes(attrs, - R.styleable.SimpleExoPlayerView, 0, 0); + TypedArray a = + context.getTheme().obtainStyledAttributes(attrs, R.styleable.SimpleExoPlayerView, 0, 0); try { shutterColorSet = a.hasValue(R.styleable.SimpleExoPlayerView_shutter_background_color); - shutterColor = a.getColor(R.styleable.SimpleExoPlayerView_shutter_background_color, - shutterColor); - playerLayoutId = a.getResourceId(R.styleable.SimpleExoPlayerView_player_layout_id, - playerLayoutId); + shutterColor = + a.getColor(R.styleable.SimpleExoPlayerView_shutter_background_color, shutterColor); + playerLayoutId = + a.getResourceId(R.styleable.SimpleExoPlayerView_player_layout_id, playerLayoutId); useArtwork = a.getBoolean(R.styleable.SimpleExoPlayerView_use_artwork, useArtwork); - defaultArtworkId = a.getResourceId(R.styleable.SimpleExoPlayerView_default_artwork, - defaultArtworkId); + defaultArtworkId = + a.getResourceId(R.styleable.SimpleExoPlayerView_default_artwork, defaultArtworkId); useController = a.getBoolean(R.styleable.SimpleExoPlayerView_use_controller, useController); surfaceType = a.getInt(R.styleable.SimpleExoPlayerView_surface_type, surfaceType); resizeMode = a.getInt(R.styleable.SimpleExoPlayerView_resize_mode, resizeMode); - controllerShowTimeoutMs = a.getInt(R.styleable.SimpleExoPlayerView_show_timeout, - controllerShowTimeoutMs); - controllerHideOnTouch = a.getBoolean(R.styleable.SimpleExoPlayerView_hide_on_touch, - controllerHideOnTouch); - controllerAutoShow = a.getBoolean(R.styleable.SimpleExoPlayerView_auto_show, - controllerAutoShow); + controllerShowTimeoutMs = + a.getInt(R.styleable.SimpleExoPlayerView_show_timeout, controllerShowTimeoutMs); + controllerHideOnTouch = + a.getBoolean(R.styleable.SimpleExoPlayerView_hide_on_touch, controllerHideOnTouch); + controllerAutoShow = + a.getBoolean(R.styleable.SimpleExoPlayerView_auto_show, controllerAutoShow); controllerHideDuringAds = a.getBoolean(R.styleable.SimpleExoPlayerView_hide_during_ads, controllerHideDuringAds); } finally { @@ -313,10 +313,13 @@ public final class SimpleExoPlayerView extends FrameLayout { // Create a surface view and insert it into the content frame, if there is one. if (contentFrame != null && surfaceType != SURFACE_TYPE_NONE) { - ViewGroup.LayoutParams params = new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); - surfaceView = surfaceType == SURFACE_TYPE_TEXTURE_VIEW ? new TextureView(context) - : new SurfaceView(context); + ViewGroup.LayoutParams params = + new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + surfaceView = + surfaceType == SURFACE_TYPE_TEXTURE_VIEW + ? new TextureView(context) + : new SurfaceView(context); surfaceView.setLayoutParams(params); contentFrame.addView(surfaceView, 0); } else { @@ -372,8 +375,10 @@ public final class SimpleExoPlayerView extends FrameLayout { * @param oldPlayerView The old view to detach from the player. * @param newPlayerView The new view to attach to the player. */ - public static void switchTargetView(@NonNull SimpleExoPlayer player, - @Nullable SimpleExoPlayerView oldPlayerView, @Nullable SimpleExoPlayerView newPlayerView) { + public static void switchTargetView( + @NonNull SimpleExoPlayer player, + @Nullable SimpleExoPlayerView oldPlayerView, + @Nullable SimpleExoPlayerView newPlayerView) { if (oldPlayerView == newPlayerView) { return; } @@ -389,21 +394,20 @@ public final class SimpleExoPlayerView extends FrameLayout { } } - /** - * Returns the player currently set on this view, or null if no player is set. - */ + /** Returns the player currently set on this view, or null if no player is set. */ public SimpleExoPlayer getPlayer() { return player; } /** * Set the {@link SimpleExoPlayer} to use. - *

- * To transition a {@link SimpleExoPlayer} from targeting one view to another, it's recommended to - * use {@link #switchTargetView(SimpleExoPlayer, SimpleExoPlayerView, SimpleExoPlayerView)} rather - * than this method. If you do wish to use this method directly, be sure to attach the player to - * the new view before calling {@code setPlayer(null)} to detach it from the old one. - * This ordering is significantly more efficient and may allow for more seamless transitions. + * + *

To transition a {@link SimpleExoPlayer} from targeting one view to another, it's recommended + * to use {@link #switchTargetView(SimpleExoPlayer, SimpleExoPlayerView, SimpleExoPlayerView)} + * rather than this method. If you do wish to use this method directly, be sure to attach the + * player to the new view before calling {@code setPlayer(null)} to detach it from the + * old one. This ordering is significantly more efficient and may allow for more seamless + * transitions. * * @param player The {@link SimpleExoPlayer} to use. */ @@ -467,9 +471,7 @@ public final class SimpleExoPlayerView extends FrameLayout { contentFrame.setResizeMode(resizeMode); } - /** - * Returns whether artwork is displayed if present in the media. - */ + /** Returns whether artwork is displayed if present in the media. */ public boolean getUseArtwork() { return useArtwork; } @@ -487,9 +489,7 @@ public final class SimpleExoPlayerView extends FrameLayout { } } - /** - * Returns the default artwork to display. - */ + /** Returns the default artwork to display. */ public Bitmap getDefaultArtwork() { return defaultArtwork; } @@ -507,9 +507,7 @@ public final class SimpleExoPlayerView extends FrameLayout { } } - /** - * Returns whether the playback controls can be shown. - */ + /** Returns whether the playback controls can be shown. */ public boolean getUseController() { return useController; } @@ -554,8 +552,8 @@ public final class SimpleExoPlayerView extends FrameLayout { overlayFrameLayout.requestFocus(); return super.dispatchKeyEvent(event); } - boolean isDpadWhenControlHidden = isDpadKey(event.getKeyCode()) && useController - && !controller.isVisible(); + boolean isDpadWhenControlHidden = + isDpadKey(event.getKeyCode()) && useController && !controller.isVisible(); maybeShowController(true); return isDpadWhenControlHidden || dispatchMediaKeyEvent(event) || super.dispatchKeyEvent(event); } @@ -574,17 +572,15 @@ public final class SimpleExoPlayerView extends FrameLayout { /** * Shows the playback controls. Does nothing if playback controls are disabled. * - *

The playback controls are automatically hidden during playback after - * {{@link #getControllerShowTimeoutMs()}}. They are shown indefinitely when playback has not - * started yet, is paused, has ended or failed. + *

The playback controls are automatically hidden during playback after {{@link + * #getControllerShowTimeoutMs()}}. They are shown indefinitely when playback has not started yet, + * is paused, has ended or failed. */ public void showController() { showController(shouldShowControllerIndefinitely()); } - /** - * Hides the playback controls. Does nothing if playback controls are disabled. - */ + /** Hides the playback controls. Does nothing if playback controls are disabled. */ public void hideController() { if (controller != null) { controller.hide(); @@ -607,8 +603,8 @@ public final class SimpleExoPlayerView extends FrameLayout { * Sets the playback controls timeout. The playback controls are automatically hidden after this * duration of time has elapsed without user input and with playback or buffering in progress. * - * @param controllerShowTimeoutMs The timeout in milliseconds. A non-positive value will cause - * the controller to remain visible indefinitely. + * @param controllerShowTimeoutMs The timeout in milliseconds. A non-positive value will cause the + * controller to remain visible indefinitely. */ public void setControllerShowTimeoutMs(int controllerShowTimeoutMs) { Assertions.checkState(controller != null); @@ -620,9 +616,7 @@ public final class SimpleExoPlayerView extends FrameLayout { } } - /** - * Returns whether the playback controls are hidden by touch events. - */ + /** Returns whether the playback controls are hidden by touch events. */ public boolean getControllerHideOnTouch() { return controllerHideOnTouch; } @@ -680,8 +674,8 @@ public final class SimpleExoPlayerView extends FrameLayout { /** * Sets the {@link ControlDispatcher}. * - * @param controlDispatcher The {@link ControlDispatcher}, or null to use - * {@link DefaultControlDispatcher}. + * @param controlDispatcher The {@link ControlDispatcher}, or null to use {@link + * DefaultControlDispatcher}. */ public void setControlDispatcher(@Nullable ControlDispatcher controlDispatcher) { Assertions.checkState(controller != null); @@ -742,11 +736,12 @@ public final class SimpleExoPlayerView extends FrameLayout { /** * Gets the view onto which video is rendered. This is a: + * *

* * @return The {@link SurfaceView}, {@link TextureView} or {@code null}. @@ -798,9 +793,7 @@ public final class SimpleExoPlayerView extends FrameLayout { return true; } - /** - * Shows the playback controls, but only if forced or shown indefinitely. - */ + /** Shows the playback controls, but only if forced or shown indefinitely. */ private void maybeShowController(boolean isForced) { if (isPlayingAd() && controllerHideDuringAds) { return; @@ -819,8 +812,10 @@ public final class SimpleExoPlayerView extends FrameLayout { return true; } int playbackState = player.getPlaybackState(); - return controllerAutoShow && (playbackState == Player.STATE_IDLE - || playbackState == Player.STATE_ENDED || !player.getPlayWhenReady()); + return controllerAutoShow + && (playbackState == Player.STATE_IDLE + || playbackState == Player.STATE_ENDED + || !player.getPlayWhenReady()); } private void showController(boolean showIndefinitely) { @@ -927,15 +922,19 @@ public final class SimpleExoPlayerView extends FrameLayout { @SuppressLint("InlinedApi") private boolean isDpadKey(int keyCode) { - return keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_UP_RIGHT - || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT || keyCode == KeyEvent.KEYCODE_DPAD_DOWN_RIGHT - || keyCode == KeyEvent.KEYCODE_DPAD_DOWN || keyCode == KeyEvent.KEYCODE_DPAD_DOWN_LEFT - || keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_UP_LEFT + return keyCode == KeyEvent.KEYCODE_DPAD_UP + || keyCode == KeyEvent.KEYCODE_DPAD_UP_RIGHT + || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT + || keyCode == KeyEvent.KEYCODE_DPAD_DOWN_RIGHT + || keyCode == KeyEvent.KEYCODE_DPAD_DOWN + || keyCode == KeyEvent.KEYCODE_DPAD_DOWN_LEFT + || keyCode == KeyEvent.KEYCODE_DPAD_LEFT + || keyCode == KeyEvent.KEYCODE_DPAD_UP_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_CENTER; } - private final class ComponentListener extends Player.DefaultEventListener implements TextOutput, - SimpleExoPlayer.VideoListener { + private final class ComponentListener extends Player.DefaultEventListener + implements TextOutput, SimpleExoPlayer.VideoListener { // TextOutput implementation @@ -949,8 +948,8 @@ public final class SimpleExoPlayerView extends FrameLayout { // SimpleExoPlayer.VideoInfoListener implementation @Override - public void onVideoSizeChanged(int width, int height, int unappliedRotationDegrees, - float pixelWidthHeightRatio) { + public void onVideoSizeChanged( + int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) { if (contentFrame != null) { float aspectRatio = height == 0 ? 1 : (width * pixelWidthHeightRatio) / height; contentFrame.setAspectRatio(aspectRatio); @@ -986,7 +985,5 @@ public final class SimpleExoPlayerView extends FrameLayout { hideController(); } } - } - }