Merge pull request #3451 from nvalletta/dev-v2-shutter-background-color
Add an easy way to set the shutter view background color
This commit is contained in:
commit
99d0a7a3da
@ -83,6 +83,12 @@ import java.util.List;
|
|||||||
* <li>Default: {@code true}</li>
|
* <li>Default: {@code true}</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* </li>
|
* </li>
|
||||||
|
* <li><b>{@code shutter_background_color}</b> - The background color of the {@code exo_shutter} view.
|
||||||
|
* <ul>
|
||||||
|
* <li>Corresponding method: {@link #setShutterBackgroundColor(int)}</li>
|
||||||
|
* <li>Default: {@code 0}</li>
|
||||||
|
* </ul>
|
||||||
|
* </li>
|
||||||
* <li><b>{@code hide_on_touch}</b> - Whether the playback controls are hidden by touch events.
|
* <li><b>{@code hide_on_touch}</b> - Whether the playback controls are hidden by touch events.
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Corresponding method: {@link #setControllerHideOnTouch(boolean)}</li>
|
* <li>Corresponding method: {@link #setControllerHideOnTouch(boolean)}</li>
|
||||||
@ -249,6 +255,7 @@ public final class SimpleExoPlayerView extends FrameLayout {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int shutterColor = 0;
|
||||||
int playerLayoutId = R.layout.exo_simple_player_view;
|
int playerLayoutId = R.layout.exo_simple_player_view;
|
||||||
boolean useArtwork = true;
|
boolean useArtwork = true;
|
||||||
int defaultArtworkId = 0;
|
int defaultArtworkId = 0;
|
||||||
@ -262,6 +269,7 @@ public final class SimpleExoPlayerView extends FrameLayout {
|
|||||||
TypedArray a = context.getTheme().obtainStyledAttributes(attrs,
|
TypedArray a = context.getTheme().obtainStyledAttributes(attrs,
|
||||||
R.styleable.SimpleExoPlayerView, 0, 0);
|
R.styleable.SimpleExoPlayerView, 0, 0);
|
||||||
try {
|
try {
|
||||||
|
shutterColor = a.getColor(R.styleable.SimpleExoPlayerView_shutter_background_color, shutterColor);
|
||||||
playerLayoutId = a.getResourceId(R.styleable.SimpleExoPlayerView_player_layout_id,
|
playerLayoutId = a.getResourceId(R.styleable.SimpleExoPlayerView_player_layout_id,
|
||||||
playerLayoutId);
|
playerLayoutId);
|
||||||
useArtwork = a.getBoolean(R.styleable.SimpleExoPlayerView_use_artwork, useArtwork);
|
useArtwork = a.getBoolean(R.styleable.SimpleExoPlayerView_use_artwork, useArtwork);
|
||||||
@ -293,6 +301,9 @@ public final class SimpleExoPlayerView extends FrameLayout {
|
|||||||
|
|
||||||
// Shutter view.
|
// Shutter view.
|
||||||
shutterView = findViewById(R.id.exo_shutter);
|
shutterView = findViewById(R.id.exo_shutter);
|
||||||
|
if (shutterView != null) {
|
||||||
|
shutterView.setBackgroundColor(shutterColor);
|
||||||
|
}
|
||||||
|
|
||||||
// Create a surface view and insert it into the content frame, if there is one.
|
// Create a surface view and insert it into the content frame, if there is one.
|
||||||
if (contentFrame != null && surfaceType != SURFACE_TYPE_NONE) {
|
if (contentFrame != null && surfaceType != SURFACE_TYPE_NONE) {
|
||||||
@ -513,6 +524,17 @@ public final class SimpleExoPlayerView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the background color of the {@code exo_shutter} view.
|
||||||
|
*
|
||||||
|
* @param color A resolved color (not a resource ID) for the background of the shutter view.
|
||||||
|
*/
|
||||||
|
public void setShutterBackgroundColor(int color) {
|
||||||
|
if (shutterView != null) {
|
||||||
|
shutterView.setBackgroundColor(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||||
if (player != null && player.isPlayingAd()) {
|
if (player != null && player.isPlayingAd()) {
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
|
|
||||||
<declare-styleable name="SimpleExoPlayerView">
|
<declare-styleable name="SimpleExoPlayerView">
|
||||||
<attr name="use_artwork" format="boolean"/>
|
<attr name="use_artwork" format="boolean"/>
|
||||||
|
<attr name="shutter_background_color" format="color" />
|
||||||
<attr name="default_artwork" format="reference"/>
|
<attr name="default_artwork" format="reference"/>
|
||||||
<attr name="use_controller" format="boolean"/>
|
<attr name="use_controller" format="boolean"/>
|
||||||
<attr name="hide_on_touch" format="boolean"/>
|
<attr name="hide_on_touch" format="boolean"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user