Skip to content

Crash when calling stop() on a mediaController playing ads #2948

@spocky

Description

@spocky

Version

Media3 pre-release (alpha, beta or RC not in this list)

More version details

No response

Devices that reproduce the issue

Nvidia Shield

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps

My app is an Android Tv launcher that fetches active sessions to get the list of android.media.session.MediaController media controllers, transforms them to androidx.media3.session.MediaController and uses them to show a "now playing" section, as well as a few controls (play/pause, next, previous, stop).

There's a crash when calling stop() while an ad is currently playing (currently tested on Spotify)

The reason is quite simple looking at the code : in the stop() implementation, the call to createSessionPositionInfo here hardcodes the parameter isPlayingAd to false.
But then, while creating the SessionPositionInfo object, a check here verifies if an ad is currently playing and throws if it doesn't match the passed parameter.

Expected result

No crash when stopping a mediaController even if an Ad is playing.

Actual result

java.lang.IllegalArgumentException
androidx.media3.common.util.Assertions.checkArgument(Assertions.java:40)
androidx.media3.session.SessionPositionInfo.<init>(SessionPositionInfo.java:83)
androidx.media3.session.MediaControllerImplLegacy.createSessionPositionInfo(MediaControllerImplLegacy.java:2487)
androidx.media3.session.MediaControllerImplLegacy.stop(MediaControllerImplLegacy.java:188)
androidx.media3.session.MediaController.stop(MediaController.java:647)

Media

Not applicable. Only depends on an ad playing, so streaming app like Spotify non-premium is probably mandatory.

Bug Report

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions