google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.74k stars 6.03k forks source link

playlist with PagedList(AAC) #5791

Closed simpler23 closed 5 years ago

simpler23 commented 5 years ago

[REQUIRED] Searched documentation and issues

I found playlist feature can be implemented using ConcatenatingMediaSource class which be added MediaSource instance.

[REQUIRED] Question

Hi, I'm implementing playlist feature that has about 700 songs. I've implemented using ConcatenatingMediaSource instance. But it require to instantiate HlsMediaSource instance about 700 times at once to add there .

I use PageList class(AAC) to show playlist in view. Is there any way to use the pageList to exoplayer playlist feature.

Is any advice in this scenario?

AquilesCanta commented 5 years ago

@tonihei can you provide advise here?

tonihei commented 5 years ago

I think the easiest solution is to create all 700 MediaSources and set the useLazyPreparation parameter is the constructor to true. This causes the source to not prepare all HLS sources at once but only if they are actually needed. This way the index in the playlist can also stay the same as the index in your PagedList and you don't need any extra logic.

simpler23 commented 5 years ago

Thank you for sharing your tip! But I worry about instantiating 700 objects at once that might not be used. Is it fine in memory perspective?

tonihei commented 5 years ago

That shouldn't be an issue. I just tested creating 700 HlsMediaSource and they use up only 233 KB of memory.

tonihei commented 5 years ago

Closing, because the question has been answered.

simpler23 commented 5 years ago

Thank you for the answers!!