diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 9258236924..29d225bda9 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -31,6 +31,9 @@ * `SubtitleView` no longer implements `TextOutput`. `SubtitleView` implements `Player.Listener`, so can be registered to a player with `Player.addListener`. + * Use `defStyleAttr` when obtaining styled attributes in + `StyledPlayerView`, `PlayerView` and `PlayerControlView` + ([#9024](https://github.com/google/ExoPlayer/issues/9024)). * Remove deprecated symbols: * Remove `Renderer.VIDEO_SCALING_MODE_*` constants. Use identically named constants in `C` instead. diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java index 2c1e469d81..7fc028ccc1 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerControlView.java @@ -377,7 +377,8 @@ public class PlayerControlView extends FrameLayout { TypedArray a = context .getTheme() - .obtainStyledAttributes(playbackAttrs, R.styleable.PlayerControlView, 0, 0); + .obtainStyledAttributes( + playbackAttrs, R.styleable.PlayerControlView, defStyleAttr, /* defStyleRes= */ 0); try { showTimeoutMs = a.getInt(R.styleable.PlayerControlView_show_timeout, showTimeoutMs); controllerLayoutId = @@ -424,8 +425,8 @@ public class PlayerControlView extends FrameLayout { if (customTimeBar != null) { timeBar = customTimeBar; } else if (timeBarPlaceholder != null) { - // Propagate attrs as timebarAttrs so that DefaultTimeBar's custom attributes are transferred, - // but standard attributes (e.g. background) are not. + // Propagate playbackAttrs as timebarAttrs so that DefaultTimeBar's custom attributes are + // transferred, but standard attributes (e.g. background) are not. DefaultTimeBar defaultTimeBar = new DefaultTimeBar(context, null, 0, playbackAttrs); defaultTimeBar.setId(R.id.exo_progress); defaultTimeBar.setLayoutParams(timeBarPlaceholder.getLayoutParams()); diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java index fa454a1813..9b36708740 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/PlayerView.java @@ -367,7 +367,11 @@ public class PlayerView extends FrameLayout implements AdViewProvider { boolean controllerHideDuringAds = true; int showBuffering = SHOW_BUFFERING_NEVER; if (attrs != null) { - TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.PlayerView, 0, 0); + TypedArray a = + context + .getTheme() + .obtainStyledAttributes( + attrs, R.styleable.PlayerView, defStyleAttr, /* defStyleRes= */ 0); try { shutterColorSet = a.hasValue(R.styleable.PlayerView_shutter_background_color); shutterColor = a.getColor(R.styleable.PlayerView_shutter_background_color, shutterColor); diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java index 277faca145..31071b7b52 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java @@ -490,7 +490,11 @@ public class StyledPlayerControlView extends FrameLayout { TypedArray a = context .getTheme() - .obtainStyledAttributes(playbackAttrs, R.styleable.StyledPlayerControlView, 0, 0); + .obtainStyledAttributes( + playbackAttrs, + R.styleable.StyledPlayerControlView, + defStyleAttr, + /* defStyleRes= */ 0); try { controllerLayoutId = a.getResourceId( @@ -575,8 +579,8 @@ public class StyledPlayerControlView extends FrameLayout { if (customTimeBar != null) { timeBar = customTimeBar; } else if (timeBarPlaceholder != null) { - // Propagate attrs as timebarAttrs so that DefaultTimeBar's custom attributes are transferred, - // but standard attributes (e.g. background) are not. + // Propagate playbackAttrs as timebarAttrs so that DefaultTimeBar's custom attributes are + // transferred, but standard attributes (e.g. background) are not. DefaultTimeBar defaultTimeBar = new DefaultTimeBar(context, null, 0, playbackAttrs, R.style.ExoStyledControls_TimeBar); defaultTimeBar.setId(R.id.exo_progress); diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java index cb8e95997c..734a3561ca 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerView.java @@ -369,7 +369,10 @@ public class StyledPlayerView extends FrameLayout implements AdViewProvider { int showBuffering = SHOW_BUFFERING_NEVER; if (attrs != null) { TypedArray a = - context.getTheme().obtainStyledAttributes(attrs, R.styleable.StyledPlayerView, 0, 0); + context + .getTheme() + .obtainStyledAttributes( + attrs, R.styleable.StyledPlayerView, defStyleAttr, /* defStyleRes= */ 0); try { shutterColorSet = a.hasValue(R.styleable.StyledPlayerView_shutter_background_color); shutterColor =