How to get all MediaItems duration in Exoplayer

313 views Asked by At

I have created a SimpleExoPlayer with mediaItems as below

   // convert each model to MediaItems
   fun ExoPlayerModel.toMediaItem(): MediaItem =
   MediaItem.fromUri(this.songUrl.toUri())

  
   // In Service Class
    val simpleExoPlayer = SimpleExoPlayer.Builder(this).build()
    // some codes
    for (model in exoPlayerModelList) {
        simpleExoPlayer.addMediaItem(model.toMediaItem())
    }
    simpleExoPlayer.prepare()

It works fine. I want to get each MediaItems duration so I will able to show it on UI.

0

There are 0 answers