简体   繁体   中英

ExoPlayer: What's the best way to handle lazy loading of a playlist?

I have a playlist with basic information about each media, I don't know anything about streaming data for the media (meaning it could be DASH, HLS, etc.) I would like to lazily create MediaSource for each media in the playlist. Meaning upon next/previous my app would create a MediaSource for the media. What would be the best way to do this?

From https://exoplayer.dev/playlists.html

It's possible to dynamically modify a playlist by adding, removing and moving MediaSources within a ConcatenatingMediaSource. This can be done both before and during playback by calling the corresponding ConcatenatingMediaSource methods. The player automatically handles modifications during playback in the correct way. For example if the currently playing MediaSource is moved, playback is not interrupted and its new successor will be played upon completion. If the currently playing MediaSource is removed, the player will automatically move to playing the first remaining successor, or transition to the ended state if no such successor exists.

You can create your sources and then just add them to the playlist with the addMediaSource call (see reference here )

Without a code example of some kind or more detail, it's hard to tell exactly what you're trying to do, but I'd expect the solution to involve you lazily creating the sources and then adding them to the playlist when they're created.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM