Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I have an issue regarding Android Auto media duration feature

I just developed media application with android automotive support everything is working fine but i have an issue with new design of automotive OS like in previous design there is no duration for media streams but now they added duration of a media i don't want it like i want to hide it because i am playing live streams. If it can't be hide then i want to to do count up timer but i do not know how to do it using media session.

here is my code for setting media session.

mediaSession.setMetadata(new MediaMetadata.Builder()
                .putString(MediaMetadata.METADATA_KEY_ARTIST, "title")
                .putString(MediaMetadata.METADATA_KEY_TITLE, "genre")
                .putLong(MediaMetadata.METADATA_KEY_DURATION, 0)
                .putString(MediaMetadata.METADATA_KEY_ALBUM_ART_URI, "https://homepages.cae.wisc.edu/~ece533/images/peppers.png")
                .build());

enter image description here

like image 829
Tara Avatar asked Oct 30 '25 22:10

Tara


1 Answers

Set a negative duration on MediaMetadata.METADATA_KEY_DURATION

A negative duration indicates that the duration is unknown (or infinite).

mediaSession.setMetadata(new MediaMetadata.Builder()
                .putString(MediaMetadata.METADATA_KEY_ARTIST, "title")
                .putString(MediaMetadata.METADATA_KEY_TITLE, "genre")
                .putLong(MediaMetadata.METADATA_KEY_DURATION, -1L) //Negative duration means the duration is unknown
                .putString(MediaMetadata.METADATA_KEY_ALBUM_ART_URI, "https://homepages.cae.wisc.edu/~ece533/images/peppers.png")
                .build());
like image 133
shb Avatar answered Nov 01 '25 11:11

shb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!