Version
Media3 1.7.1 (same as 1.6.1)
More version details
No response
Devices that reproduce the issue
any
Devices that do not reproduce the issue
none
Reproducible in the demo app?
No
Reproduction steps
The issue seems to stem from androidx/media3/session/PlayerWrapper.java:713:
public Timeline getCurrentTimelineWithCommandCheck() {
if (isCommandAvailable(COMMAND_GET_TIMELINE)) {
return getCurrentTimeline();
} else if (isCommandAvailable(COMMAND_GET_CURRENT_MEDIA_ITEM)) {
return getCurrentTimeline().isEmpty() // illegal access
? Timeline.EMPTY
: new CurrentMediaItemOnlyTimeline(this);
}
return Timeline.EMPTY;
}
- Create your own implementation of the
androidx.media3.common.Player interface.
- Specify
COMMAND_GET_CURRENT_MEDIA_ITEM as available and implement related interface functions
- Specifically do not specify
COMMAND_GET_TIMELINE as available and do not implement related methods, specifically getCurrentTimeline(). For example throw UnsupportedOperationException
- Wrap your Player using
PlayerWrapper, for example by using it in a MediaSession.Builder
Expected result
getCurrentTimeline() is not being called, as COMMAND_GET_TIMELINE is unavailable -> no crash is occuring
This would respect the documentation:
This method must only be called if COMMAND_GET_TIMELINE is available.
Actual result
getCurrentTimeline() is being called, even though COMMAND_GET_TIMELINE is unavailable -> the application crashes.
This does not respect the documentation:
This method must only be called if COMMAND_GET_TIMELINE is available.
stacktrace:
FATAL EXCEPTION: main
Process: com.example.myapp, PID: 19150
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapp/com.example.myapp.MainActivity}: java.lang.UnsupportedOperationException: getCurrentTimeline() is not supported since COMMAND_GET_TIMELINE is not advertised
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4280)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4467)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:222)
at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:133)
at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:103)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:80)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2823)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loopOnce(Looper.java:248)
at android.os.Looper.loop(Looper.java:338)
at android.app.ActivityThread.main(ActivityThread.java:9067)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:932)
Caused by: java.lang.UnsupportedOperationException: getCurrentTimeline() is not supported since COMMAND_GET_TIMELINE is not advertised
at com.example.myapp.MyPlayer.getCurrentTimeline(MyPlayer.kt:45)
at androidx.media3.common.ForwardingPlayer.getCurrentTimeline(ForwardingPlayer.java:527)
at androidx.media3.session.PlayerWrapper.getCurrentTimeline(PlayerWrapper.java:706)
at androidx.media3.session.PlayerWrapper.getCurrentTimelineWithCommandCheck(PlayerWrapper.java:713)
at androidx.media3.session.MediaSessionLegacyStub$ControllerLegacyCbForBroadcast.onPlayerChanged(MediaSessionLegacyStub.java:1067)
at androidx.media3.session.MediaSessionImpl.lambda$setPlayerInternal$1(MediaSessionImpl.java:295)
at androidx.media3.session.MediaSessionImpl$$ExternalSyntheticLambda2.run(D8$$SyntheticClass:0)
at androidx.media3.session.MediaSessionImpl.dispatchRemoteControllerTaskToLegacyStub(MediaSessionImpl.java:1070)
at androidx.media3.session.MediaSessionImpl.setPlayerInternal(MediaSessionImpl.java:294)
at androidx.media3.session.MediaSessionImpl.lambda$new$0(MediaSessionImpl.java:259)
at androidx.media3.session.MediaSessionImpl$$ExternalSyntheticLambda31.run(D8$$SyntheticClass:0)
at androidx.media3.common.util.Util.postOrRun(Util.java:800)
at androidx.media3.session.MediaSessionImpl.<init>(MediaSessionImpl.java:256)
at androidx.media3.session.MediaSession.createImpl(MediaSession.java:744)
at androidx.media3.session.MediaSession.<init>(MediaSession.java:712)
at androidx.media3.session.MediaSession$Builder.build(MediaSession.java:496)
at com.example.myapp.MainActivity.onCreate(MainActivity.kt:23)
at android.app.Activity.performCreate(Activity.java:9155)
at android.app.Activity.performCreate(Activity.java:9133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1521)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4262)
... 13 more
Media
Not applicable
Bug Report
Version
Media3 1.7.1 (same as 1.6.1)
More version details
No response
Devices that reproduce the issue
any
Devices that do not reproduce the issue
none
Reproducible in the demo app?
No
Reproduction steps
The issue seems to stem from androidx/media3/session/PlayerWrapper.java:713:
androidx.media3.common.Playerinterface.COMMAND_GET_CURRENT_MEDIA_ITEMas available and implement related interface functionsCOMMAND_GET_TIMELINEas available and do not implement related methods, specificallygetCurrentTimeline(). For example throwUnsupportedOperationExceptionPlayerWrapper, for example by using it in aMediaSession.BuilderExpected result
getCurrentTimeline()is not being called, asCOMMAND_GET_TIMELINEis unavailable -> no crash is occuringThis would respect the documentation:
Actual result
getCurrentTimeline()is being called, even thoughCOMMAND_GET_TIMELINEis unavailable -> the application crashes.This does not respect the documentation:
stacktrace:
Media
Not applicable
Bug Report
adb bugreportto android-media-github@google.com after filing this issue.