androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.73k stars 414 forks source link

Logged RuntimeException when overriding controls drawables #220

Open moneytoo opened 1 year ago

moneytoo commented 1 year ago

Media3 Version

1.0.0-beta03

Devices that reproduce the issue

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

  1. Add following drawable resources to the demo app:

ic_outline_play_arrow_24.xml:

<vector android:height="24dp" android:tint="#FFFFFF"
    android:viewportHeight="24" android:viewportWidth="24"
    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="@android:color/white" android:pathData="M10,8.64L15.27,12 10,15.36V8.64M8,5v14l11,-7L8,5z"/>
</vector>

controls_gradient.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval" >
    <size
        android:width="40dp"
        android:height="40dp" />
    <gradient
        android:centerColor="#AAFF0000"
        android:endColor="#00FF0000"
        android:gradientRadius="50%p"
        android:startColor="#00FF0000"
        android:type="radial" />
</shape>

exo_styled_controls_play.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/controls_gradient"/>
    <item
        android:drawable="@drawable/ic_outline_play_arrow_24"
        android:top="3dp"
        android:left="3dp"
        android:right="3dp"
        android:bottom="3dp">
    </item>
</layer-list>
  1. Open any media so that controls with the play button is visible

Expected result

No logged exception

Actual result

Every time each overriden control is shown, following exception is logged:

Drawable androidx.media3.demo.main:drawable/exo_styled_controls_play has unresolved theme attributes! Consider using Resources.getDrawable(int, Theme) or Context.getDrawable(int).
java.lang.RuntimeException
    at android.content.res.Resources.getDrawable(Resources.java:967)
    at androidx.media3.ui.PlayerControlView.updatePlayPauseButton(PlayerControlView.java:965)
    at androidx.media3.ui.PlayerControlView.access$300(PlayerControlView.java:181)
    at androidx.media3.ui.PlayerControlView$ComponentListener.onEvents(PlayerControlView.java:1583)
    at androidx.media3.exoplayer.ExoPlayerImpl.lambda$new$0$androidx-media3-exoplayer-ExoPlayerImpl(ExoPlayerImpl.java:276)
    at androidx.media3.exoplayer.ExoPlayerImpl$$ExternalSyntheticLambda18.invoke(Unknown Source:4)
    at androidx.media3.common.util.ListenerSet$ListenerHolder.iterationFinished(ListenerSet.java:295)
    at androidx.media3.common.util.ListenerSet.handleMessage(ListenerSet.java:246)
    at androidx.media3.common.util.ListenerSet.$r8$lambda$bio3pd12v5B_9b5UeFaPn9XBQ90(Unknown Source:0)
    at androidx.media3.common.util.ListenerSet$$ExternalSyntheticLambda0.handleMessage(Unknown Source:2)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8741)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Media

Not applicable

Bug Report

marcbaechinger commented 1 year ago

Thanks for reporting! I can repro this. We will provide a fix for this.