3

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

Tara
  • 692
  • 5
  • 23

1 Answers1

5

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());
shb
  • 5,957
  • 2
  • 15
  • 32
  • 2
    i did this but it shows 00:00 as a duration.... how can i start count up timer or hide this textview any idea? – Tara Aug 26 '19 at 08:22
  • i am using exoplayer to play media live streams – Tara Aug 26 '19 at 08:33
  • here is my question on Android Auto community https://support.google.com/androidauto/thread/12400850?hl=en&pli=1# – Tara Aug 27 '19 at 08:22