I have an issue regarding Android Auto media duration feature

787 views Asked by At

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

1

There are 1 answers

3
shb On

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());