How to remove duration and progress indicator in Android Auto when playing live stream
I'm working on an app that plays a live-stream for a radio station that also needs Android Auto support. I'm trying to find a way to hide the progress indicator and duration (which seems to default to 1:40) on the Android Auto UI, given it doesn't make sense for a live stream. Looking at https://github.com/androidx/media/issues/339 I assumed maybe there was a player/session command to control this, but I've tried a few with no luck so far. Does a command (or any other way to control this programmatically) exist?
We fixed https://github.com/androidx/media/issues/1256 in Media3 1.4.0, that sounds like the exact same issue. Which version are you using at the moment?
@jqi26 I managed to remove the progress bar by setting the METADATA_KEY_DURATION extra to -1 on MediaMetadata.extras.
But I have the same issue, @tonihei, in that I don't know what to set to remove the duration in Android Auto, which is just showing the duration of the live buffer which is not very useful nor user friendly.
@albinus-sc : Same question as above - is this still happening with 1.4.0 or are you on an earlier version? I believe we fixed this, so it would be good to know in which circumstances it still shows up the live buffer duration. If you have a reproducible example on the latest version, please share more details so we can take a look. You can also send test media links to [email protected] and report back here if you don't want to share it publicly.
@tonihei Yes, we're using 1.4.1.
I'm not sure how to give a reproducible example. But I can say that our live buffer is about half an hour, and that half hour is what gets pasted into the duration on Android Auto. It works as intended in the media notification on Android 14. No duration is shown there, and no progress bar either.
@tonihei I have sent the HLS stream link we use to the provided email address.
Thanks @tonihei . No we're still on 1.3.1, can confirm I get the same result as @albinus-sc after upgrading.
1.3.1:
1.4.1:
Ideally it would be possible to get rid of the progress bar and time elapsed entirely? Though I see the bar is in the notification as well. Also tried seeing what happens in the Media3 sample when I stick our m3u8 file there; I get this:
Similarly the time elapsed keeps resetting to zero seconds, ideally these elements aren't there at all.
Hi the same issue for me, I added in this way but it has no effect
val extras = Bundle().apply {
putLong(MediaMetadataCompat.METADATA_KEY_DURATION, C.TIME_UNSET)
}
val playbackStateBuilder = PlaybackStateCompat.Builder().apply {
setState(PlaybackStateCompat.STATE_PLAYING, C.TIME_UNSET, 1f, C.TIME_UNSET)
setActions(PlaybackStateCompat.ACTION_PAUSE)
setExtras(extras)
}
mMediaSession?.setPlaybackState(playbackStateBuilder.build())
The same behaviour using a `-1` instead of `C.TIME_UNSET`. I am using legacy instead of Media3.
POSSIBLE HINT: maybe it could be resolved by hiding the field using reflection ? @tonihei
@tonihei Hey, any update on this issue?
@tonihei Also hoping to get this resolved in my Android Auto app.
@tonihei Hi, we would also benefit from this fix for a radio streaming Android Auto app.
I tried multiple things to control the duration and found no viable option. Hiding the duration completely would be a lifesaver. Please!
I tried this out and wasn't able to completely remove the progress bar and the position value.
We can submit a fix in Media3 that makes sure the position doesn't start advancing in this weird way and the scrubber disappears. But it will still show the progress bar itself and a static position of 0:00.
The changes mentioned above are submitted now. Closing the issue. If you think there is a way to remove the disabled seekbar or 0:00 position info entirely, please let us know and we can take another look.
Hello @tonihei
In the legacy Android media APIs, setting METADATA_KEY_DURATION to a negative value signaled that the duration was unknown (or effectively infinite). With Media3, MediaMetadata.Builder#setDurationMs(long) is documented to accept non‑negative values only.
Is Media3's documentation going to be updated to reflect specifications for infinite content?
With Media3, MediaMetadata.Builder#setDurationMs(long) is documented to accept non‑negative values only.
This setter accepts null to indicate unset (the signature takes Long, not long).
It does indeed @icbaker. However, the documentation is not as explicit as it is for the legacy Media APIs https://developer.android.com/reference/android/media/MediaMetadata#METADATA_KEY_DURATION "A negative duration indicates that the duration is unknown (or infinite)."
https://developer.android.com/reference/androidx/media3/common/MediaMetadata.Builder#setDurationMs(java.lang.Long) "Sets the optional duration, non-negative and in milliseconds."
Are you asking us to make it clearer that null means 'unknown'? (this seems implicit to me on an API that takes @Nullable and already documents the set value as 'optional')
Or are you asking us to make it more clear that 'unknown' is a synonymn for 'infinite'?
I don't think we are likely to do the latter, since there are cases where duration is not known but the stream is not infinite (or at least, we don't know it's infinite).
I believe it would help if the documentation explicitly stated that leaving the duration unset, by passing null or simply not calling setDurationMs, replaces the old practice of supplying a negative duration, and is how to indicate an unknown or unbounded (infinite) duration.
There has been a few developers that have found the current wording unclear and aren't sure how to properly specify infinite content, so a brief clarification (similarly to how it was worded in the legacy Media documentation. It never stated that infinite was a synonym to unkown; "A negative duration indicates that the duration is unknown (OR infinite).") would close that gap :)