From c70cd37c5a28e6b7fa2e9b87c032ff5a2b501ee4 Mon Sep 17 00:00:00 2001 From: tonihei Date: Mon, 8 May 2017 09:19:56 -0700 Subject: [PATCH] Repeat mode UI Added repeat mode toggle buttons to UI. Current mode gets forwarded to Exoplayer instance, but without playback behaviour changes yet. Translations for button descriptions are also missing - this will be another CL. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=155386549 --- .../android/exoplayer2/demo/EventLogger.java | 4 + .../google/android/exoplayer2/ExoPlayer.java | 10 +- .../exoplayer2/ui/PlaybackControlView.java | 171 +++++++++++++++++- .../exoplayer2/ui/SimpleExoPlayerView.java | 10 + .../exo_controls_repeat_all.xml | 23 +++ .../exo_controls_repeat_off.xml | 23 +++ .../exo_controls_repeat_one.xml | 23 +++ .../drawable-hdpi/exo_controls_repeat_all.png | Bin 0 -> 203 bytes .../drawable-hdpi/exo_controls_repeat_off.png | Bin 0 -> 223 bytes .../drawable-hdpi/exo_controls_repeat_one.png | Bin 0 -> 223 bytes .../drawable-ldpi/exo_controls_repeat_all.png | Bin 0 -> 142 bytes .../drawable-ldpi/exo_controls_repeat_off.png | Bin 0 -> 166 bytes .../drawable-ldpi/exo_controls_repeat_one.png | Bin 0 -> 160 bytes .../drawable-mdpi/exo_controls_repeat_all.png | Bin 0 -> 210 bytes .../drawable-mdpi/exo_controls_repeat_off.png | Bin 0 -> 227 bytes .../drawable-mdpi/exo_controls_repeat_one.png | Bin 0 -> 232 bytes .../exo_controls_repeat_all.png | Bin 0 -> 288 bytes .../exo_controls_repeat_off.png | Bin 0 -> 322 bytes .../exo_controls_repeat_one.png | Bin 0 -> 331 bytes .../exo_controls_repeat_all.png | Bin 0 -> 266 bytes .../exo_controls_repeat_off.png | Bin 0 -> 309 bytes .../exo_controls_repeat_one.png | Bin 0 -> 309 bytes .../res/layout/exo_playback_control_view.xml | 3 + library/ui/src/main/res/values/attrs.xml | 6 + library/ui/src/main/res/values/ids.xml | 1 + 25 files changed, 272 insertions(+), 2 deletions(-) create mode 100644 library/ui/src/main/res/drawable-anydpi-v21/exo_controls_repeat_all.xml create mode 100644 library/ui/src/main/res/drawable-anydpi-v21/exo_controls_repeat_off.xml create mode 100644 library/ui/src/main/res/drawable-anydpi-v21/exo_controls_repeat_one.xml create mode 100644 library/ui/src/main/res/drawable-hdpi/exo_controls_repeat_all.png create mode 100644 library/ui/src/main/res/drawable-hdpi/exo_controls_repeat_off.png create mode 100644 library/ui/src/main/res/drawable-hdpi/exo_controls_repeat_one.png create mode 100644 library/ui/src/main/res/drawable-ldpi/exo_controls_repeat_all.png create mode 100644 library/ui/src/main/res/drawable-ldpi/exo_controls_repeat_off.png create mode 100644 library/ui/src/main/res/drawable-ldpi/exo_controls_repeat_one.png create mode 100644 library/ui/src/main/res/drawable-mdpi/exo_controls_repeat_all.png create mode 100644 library/ui/src/main/res/drawable-mdpi/exo_controls_repeat_off.png create mode 100644 library/ui/src/main/res/drawable-mdpi/exo_controls_repeat_one.png create mode 100644 library/ui/src/main/res/drawable-xhdpi/exo_controls_repeat_all.png create mode 100644 library/ui/src/main/res/drawable-xhdpi/exo_controls_repeat_off.png create mode 100644 library/ui/src/main/res/drawable-xhdpi/exo_controls_repeat_one.png create mode 100644 library/ui/src/main/res/drawable-xxhdpi/exo_controls_repeat_all.png create mode 100644 library/ui/src/main/res/drawable-xxhdpi/exo_controls_repeat_off.png create mode 100644 library/ui/src/main/res/drawable-xxhdpi/exo_controls_repeat_one.png diff --git a/demo/src/main/java/com/google/android/exoplayer2/demo/EventLogger.java b/demo/src/main/java/com/google/android/exoplayer2/demo/EventLogger.java index 0d77624a7b..686718f9e0 100644 --- a/demo/src/main/java/com/google/android/exoplayer2/demo/EventLogger.java +++ b/demo/src/main/java/com/google/android/exoplayer2/demo/EventLogger.java @@ -470,6 +470,10 @@ import java.util.Locale; switch (repeatMode) { case ExoPlayer.REPEAT_MODE_OFF: return "OFF"; + case ExoPlayer.REPEAT_MODE_ONE: + return "ONE"; + case ExoPlayer.REPEAT_MODE_ALL: + return "ALL"; default: return "?"; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java index 6327ebd9c2..8e16de5fca 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java @@ -268,12 +268,20 @@ public interface ExoPlayer { * Repeat modes for playback. */ @Retention(RetentionPolicy.SOURCE) - @IntDef({REPEAT_MODE_OFF}) + @IntDef({REPEAT_MODE_OFF, REPEAT_MODE_ONE, REPEAT_MODE_ALL}) public @interface RepeatMode {} /** * Normal playback without repetition. */ int REPEAT_MODE_OFF = 0; + /** + * "Repeat One" mode to repeat the currently playing window infinitely. + */ + int REPEAT_MODE_ONE = 1; + /** + * "Repeat All" mode to repeat the entire timeline infinitely. + */ + int REPEAT_MODE_ALL = 2; /** * Register a listener to receive events from the player. The listener's methods will be called on 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 ae5b7c8b13..337cb47b1e 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 @@ -18,13 +18,17 @@ package com.google.android.exoplayer2.ui; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.Context; +import android.content.res.Resources; import android.content.res.TypedArray; +import android.graphics.drawable.Drawable; import android.os.SystemClock; +import android.support.annotation.IntDef; import android.util.AttributeSet; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.widget.FrameLayout; +import android.widget.ImageView; import android.widget.TextView; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.ExoPlaybackException; @@ -35,6 +39,8 @@ import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Util; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.Arrays; import java.util.Formatter; import java.util.Locale; @@ -70,6 +76,14 @@ import java.util.Locale; *
  • Default: {@link #DEFAULT_FAST_FORWARD_MS}
  • * * + *
  • {@code repeat_toggle_modes} - A flagged enumeration value specifying which repeat + * mode toggle options are enabled. Valid values are: {@code none}, {@code one}, + * {@code all}, or {@code one|all}. + * + *
  • *
  • {@code controller_layout_id} - Specifies the id of the layout to be inflated. See * below for more details. * *
  • + *
  • {@code exo_repeat_toggle} - The repeat toggle button. + * + *
  • *
  • {@code exo_position} - Text view displaying the current playback position. *