Commit c4b4e845 by Oliver Woodman

Add artwork support to SimpleExoPlayerView + misc improvements

parent 0c8f3c72
...@@ -71,36 +71,30 @@ import com.google.android.exoplayer2.util.Util; ...@@ -71,36 +71,30 @@ import com.google.android.exoplayer2.util.Util;
// Standard genres. // Standard genres.
private static final String[] STANDARD_GENRES = new String[] { private static final String[] STANDARD_GENRES = new String[] {
// These are the official ID3v1 genres. // These are the official ID3v1 genres.
"Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge", "Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge", "Hip-Hop", "Jazz",
"Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B", "Rap", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B", "Rap", "Reggae", "Rock", "Techno",
"Reggae", "Rock", "Techno", "Industrial", "Alternative", "Ska", "Industrial", "Alternative", "Ska", "Death Metal", "Pranks", "Soundtrack", "Euro-Techno",
"Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient", "Ambient", "Trip-Hop", "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical", "Instrumental",
"Trip-Hop", "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical", "Acid", "House", "Game", "Sound Clip", "Gospel", "Noise", "AlternRock", "Bass", "Soul",
"Instrumental", "Acid", "House", "Game", "Sound Clip", "Gospel", "Noise", "Punk", "Space", "Meditative", "Instrumental Pop", "Instrumental Rock", "Ethnic", "Gothic",
"AlternRock", "Bass", "Soul", "Punk", "Space", "Meditative", "Darkwave", "Techno-Industrial", "Electronic", "Pop-Folk", "Eurodance", "Dream",
"Instrumental Pop", "Instrumental Rock", "Ethnic", "Gothic", "Darkwave", "Southern Rock", "Comedy", "Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle",
"Techno-Industrial", "Electronic", "Pop-Folk", "Eurodance", "Dream", "Native American", "Cabaret", "New Wave", "Psychadelic", "Rave", "Showtunes", "Trailer",
"Southern Rock", "Comedy", "Cult", "Gangsta", "Top 40", "Christian Rap", "Lo-Fi", "Tribal", "Acid Punk", "Acid Jazz", "Polka", "Retro", "Musical", "Rock & Roll",
"Pop/Funk", "Jungle", "Native American", "Cabaret", "New Wave",
"Psychadelic", "Rave", "Showtunes", "Trailer", "Lo-Fi", "Tribal",
"Acid Punk", "Acid Jazz", "Polka", "Retro", "Musical", "Rock & Roll",
"Hard Rock", "Hard Rock",
// These were made up by the authors of Winamp but backported into the ID3 spec. // These were made up by the authors of Winamp and later added to the ID3 spec.
"Folk", "Folk-Rock", "National Folk", "Swing", "Fast Fusion", "Folk", "Folk-Rock", "National Folk", "Swing", "Fast Fusion", "Bebob", "Latin", "Revival",
"Bebob", "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", "Progressive Rock", "Psychedelic Rock",
"Gothic Rock", "Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Symphonic Rock", "Slow Rock", "Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour",
"Slow Rock", "Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech", "Chanson", "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass", "Primus",
"Speech", "Chanson", "Opera", "Chamber Music", "Sonata", "Symphony", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba", "Folklore", "Ballad",
"Booty Bass", "Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Power Ballad", "Rhythmic Soul", "Freestyle", "Duet", "Punk Rock", "Drum Solo", "A capella",
"Tango", "Samba", "Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Euro-House", "Dance Hall",
"Freestyle", "Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House", // These were med up by the authors of Winamp but have not been added to the ID3 spec.
"Dance Hall", "Goa", "Drum & Bass", "Club-House", "Hardcore", "Terror", "Indie", "BritPop", "Negerpunk",
// These were also invented by the Winamp folks but ignored by the ID3 authors. "Polsk Punk", "Beat", "Christian Gangsta Rap", "Heavy Metal", "Black Metal", "Crossover",
"Goa", "Drum & Bass", "Club-House", "Hardcore", "Terror", "Indie", "Contemporary Christian", "Christian Rock", "Merengue", "Salsa", "Thrash Metal", "Anime",
"BritPop", "Negerpunk", "Polsk Punk", "Beat", "Christian Gangsta Rap", "Jpop", "Synthpop"
"Heavy Metal", "Black Metal", "Crossover", "Contemporary Christian",
"Christian Rock", "Merengue", "Salsa", "Thrash Metal", "Anime", "Jpop",
"Synthpop"
}; };
private static final String LANGUAGE_UNDEFINED = "und"; private static final String LANGUAGE_UNDEFINED = "und";
......
...@@ -17,10 +17,13 @@ package com.google.android.exoplayer2.ui; ...@@ -17,10 +17,13 @@ package com.google.android.exoplayer2.ui;
import android.content.Context; import android.content.Context;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.support.annotation.IntDef;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import com.google.android.exoplayer2.R; import com.google.android.exoplayer2.R;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/** /**
* A {@link FrameLayout} that resizes itself to match a specified aspect ratio. * A {@link FrameLayout} that resizes itself to match a specified aspect ratio.
...@@ -28,6 +31,13 @@ import com.google.android.exoplayer2.R; ...@@ -28,6 +31,13 @@ import com.google.android.exoplayer2.R;
public final class AspectRatioFrameLayout extends FrameLayout { public final class AspectRatioFrameLayout extends FrameLayout {
/** /**
* Resize modes for {@link AspectRatioFrameLayout}.
*/
@Retention(RetentionPolicy.SOURCE)
@IntDef({RESIZE_MODE_FIT, RESIZE_MODE_FIXED_WIDTH, RESIZE_MODE_FIXED_HEIGHT})
public @interface ResizeMode {}
/**
* Either the width or height is decreased to obtain the desired aspect ratio. * Either the width or height is decreased to obtain the desired aspect ratio.
*/ */
public static final int RESIZE_MODE_FIT = 0; public static final int RESIZE_MODE_FIT = 0;
...@@ -85,12 +95,11 @@ public final class AspectRatioFrameLayout extends FrameLayout { ...@@ -85,12 +95,11 @@ public final class AspectRatioFrameLayout extends FrameLayout {
} }
/** /**
* Sets the resize mode which can be of value {@link #RESIZE_MODE_FIT}, * Sets the resize mode.
* {@link #RESIZE_MODE_FIXED_HEIGHT} or {@link #RESIZE_MODE_FIXED_WIDTH}.
* *
* @param resizeMode The resize mode. * @param resizeMode The resize mode.
*/ */
public void setResizeMode(int resizeMode) { public void setResizeMode(@ResizeMode int resizeMode) {
if (this.resizeMode != resizeMode) { if (this.resizeMode != resizeMode) {
this.resizeMode = resizeMode; this.resizeMode = resizeMode;
requestLayout(); requestLayout();
......
...@@ -120,7 +120,7 @@ public class PlaybackControlView extends FrameLayout { ...@@ -120,7 +120,7 @@ public class PlaybackControlView extends FrameLayout {
public PlaybackControlView(Context context, AttributeSet attrs, int defStyleAttr) { public PlaybackControlView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr); super(context, attrs, defStyleAttr);
int layoutResourceId = R.layout.exo_playback_control_view; int controllerLayoutId = R.layout.exo_playback_control_view;
rewindMs = DEFAULT_REWIND_MS; rewindMs = DEFAULT_REWIND_MS;
fastForwardMs = DEFAULT_FAST_FORWARD_MS; fastForwardMs = DEFAULT_FAST_FORWARD_MS;
showTimeoutMs = DEFAULT_SHOW_TIMEOUT_MS; showTimeoutMs = DEFAULT_SHOW_TIMEOUT_MS;
...@@ -132,8 +132,8 @@ public class PlaybackControlView extends FrameLayout { ...@@ -132,8 +132,8 @@ public class PlaybackControlView extends FrameLayout {
fastForwardMs = a.getInt(R.styleable.PlaybackControlView_fastforward_increment, fastForwardMs = a.getInt(R.styleable.PlaybackControlView_fastforward_increment,
fastForwardMs); fastForwardMs);
showTimeoutMs = a.getInt(R.styleable.PlaybackControlView_show_timeout, showTimeoutMs); showTimeoutMs = a.getInt(R.styleable.PlaybackControlView_show_timeout, showTimeoutMs);
layoutResourceId = a.getResourceId(R.styleable.PlaybackControlView_controller_layout_id, controllerLayoutId = a.getResourceId(R.styleable.PlaybackControlView_controller_layout_id,
layoutResourceId); controllerLayoutId);
} finally { } finally {
a.recycle(); a.recycle();
} }
...@@ -143,7 +143,7 @@ public class PlaybackControlView extends FrameLayout { ...@@ -143,7 +143,7 @@ public class PlaybackControlView extends FrameLayout {
formatter = new Formatter(formatBuilder, Locale.getDefault()); formatter = new Formatter(formatBuilder, Locale.getDefault());
componentListener = new ComponentListener(); componentListener = new ComponentListener();
LayoutInflater.from(context).inflate(layoutResourceId, this); LayoutInflater.from(context).inflate(controllerLayoutId, this);
time = (TextView) findViewById(R.id.exo_time); time = (TextView) findViewById(R.id.exo_time);
timeCurrent = (TextView) findViewById(R.id.exo_time_current); timeCurrent = (TextView) findViewById(R.id.exo_time_current);
progressBar = (SeekBar) findViewById(R.id.exo_progress); progressBar = (SeekBar) findViewById(R.id.exo_progress);
......
...@@ -28,22 +28,22 @@ ...@@ -28,22 +28,22 @@
android:paddingTop="4dp" android:paddingTop="4dp"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageButton android:id="@+id/exo_prev" <ImageButton android:id="@id/exo_prev"
style="@style/ExoMediaButton.Previous"/> style="@style/ExoMediaButton.Previous"/>
<ImageButton android:id="@+id/exo_rew" <ImageButton android:id="@id/exo_rew"
style="@style/ExoMediaButton.Rewind"/> style="@style/ExoMediaButton.Rewind"/>
<ImageButton android:id="@+id/exo_play" <ImageButton android:id="@id/exo_play"
style="@style/ExoMediaButton.Play"/> style="@style/ExoMediaButton.Play"/>
<ImageButton android:id="@+id/exo_pause" <ImageButton android:id="@id/exo_pause"
style="@style/ExoMediaButton.Pause"/> style="@style/ExoMediaButton.Pause"/>
<ImageButton android:id="@+id/exo_ffwd" <ImageButton android:id="@id/exo_ffwd"
style="@style/ExoMediaButton.FastForward"/> style="@style/ExoMediaButton.FastForward"/>
<ImageButton android:id="@+id/exo_next" <ImageButton android:id="@id/exo_next"
style="@style/ExoMediaButton.Next"/> style="@style/ExoMediaButton.Next"/>
</LinearLayout> </LinearLayout>
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView android:id="@+id/exo_time_current" <TextView android:id="@id/exo_time_current"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
...@@ -64,13 +64,13 @@ ...@@ -64,13 +64,13 @@
android:paddingEnd="4dp" android:paddingEnd="4dp"
android:textColor="#FFBEBEBE"/> android:textColor="#FFBEBEBE"/>
<SeekBar android:id="@+id/exo_progress" <SeekBar android:id="@id/exo_progress"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="32dp" android:layout_height="32dp"
style="?android:attr/progressBarStyleHorizontal"/> style="?android:attr/progressBarStyleHorizontal"/>
<TextView android:id="@+id/exo_time" <TextView android:id="@id/exo_time"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
......
...@@ -17,23 +17,28 @@ ...@@ -17,23 +17,28 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_width="match_parent"> android:layout_width="match_parent">
<com.google.android.exoplayer2.ui.AspectRatioFrameLayout android:id="@+id/exo_video_frame" <com.google.android.exoplayer2.ui.AspectRatioFrameLayout android:id="@id/exo_video_frame"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center"> android:layout_gravity="center">
<View android:id="@+id/exo_shutter" <View android:id="@id/exo_shutter"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@android:color/black"/> android:background="@android:color/black"/>
<com.google.android.exoplayer2.ui.SubtitleView android:id="@+id/exo_subtitles" <com.google.android.exoplayer2.ui.SubtitleView android:id="@id/exo_subtitles"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent"/>
</com.google.android.exoplayer2.ui.AspectRatioFrameLayout> </com.google.android.exoplayer2.ui.AspectRatioFrameLayout>
<View android:id="@+id/exo_controller_placeholder" <ImageView android:id="@id/exo_artwork"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitCenter"/>
<View android:id="@id/exo_controller_placeholder"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent"/>
......
...@@ -14,24 +14,33 @@ ...@@ -14,24 +14,33 @@
limitations under the License. limitations under the License.
--> -->
<resources> <resources>
<!-- Must be kept in sync with AspectRatioFrameLayout -->
<attr name="resize_mode" format="enum"> <attr name="resize_mode" format="enum">
<enum name="fit" value="0"/> <enum name="fit" value="0"/>
<enum name="fixed_width" value="1"/> <enum name="fixed_width" value="1"/>
<enum name="fixed_height" value="2"/> <enum name="fixed_height" value="2"/>
</attr> </attr>
<!-- Must be kept in sync with SimpleExoPlayerView -->
<attr name="surface_type" format="enum">
<enum name="none" value="0"/>
<enum name="surface_view" value="1"/>
<enum name="texture_view" value="2"/>
</attr>
<attr name="show_timeout" format="integer"/> <attr name="show_timeout" format="integer"/>
<attr name="rewind_increment" format="integer"/> <attr name="rewind_increment" format="integer"/>
<attr name="fastforward_increment" format="integer"/> <attr name="fastforward_increment" format="integer"/>
<attr name="player_layout_id" format="reference"/>
<attr name="controller_layout_id" format="reference"/> <attr name="controller_layout_id" format="reference"/>
<declare-styleable name="SimpleExoPlayerView"> <declare-styleable name="SimpleExoPlayerView">
<attr name="use_artwork" format="boolean"/>
<attr name="use_controller" format="boolean"/> <attr name="use_controller" format="boolean"/>
<attr name="use_texture_view" format="boolean"/> <attr name="surface_type"/>
<attr name="show_timeout"/> <attr name="show_timeout"/>
<attr name="rewind_increment"/> <attr name="rewind_increment"/>
<attr name="fastforward_increment"/> <attr name="fastforward_increment"/>
<attr name="resize_mode"/> <attr name="resize_mode"/>
<attr name="player_layout_id"/>
<attr name="controller_layout_id"/> <attr name="controller_layout_id"/>
</declare-styleable> </declare-styleable>
......
...@@ -14,6 +14,12 @@ ...@@ -14,6 +14,12 @@
limitations under the License. limitations under the License.
--> -->
<resources> <resources>
<item name="exo_video_frame" type="id"/>
<item name="exo_shutter" type="id"/>
<item name="exo_subtitles" type="id"/>
<item name="exo_artwork" type="id"/>
<item name="exo_controller_placeholder" type="id"/>
<item name="exo_controller" type="id"/>
<item name="exo_play" type="id"/> <item name="exo_play" type="id"/>
<item name="exo_pause" type="id"/> <item name="exo_pause" type="id"/>
<item name="exo_rew" 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