question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Media item downloaded repeatedly when repeat mode is Player.REPEAT_MODE_ONE

See original GitHub issue

[REQUIRED] Issue description

In 2.12.0, ExoPlayer will repeatedly download MediaItem until released, wasting user bandwidth.

https://i.imgur.com/nZDROLY.png All these requests happened within 10 seconds of playing.

[REQUIRED] Reproduction steps

Simply prepare a SimpleExoPlayer like so and check the network logs using your favorite MITM inspector.

exoPlayer.setMediaItem(MediaItem.fromUri("https://i.imgur.com/dgNL2jK.mp4"))
exoPlayer.prepare()
exoPlayer.repeatMode = Player.REPEAT_MODE_ONE
exoPlayer.seekTo(playbackTime)

This only happens with the new .setMediaItem() & .prepare() API. The deprecated .prepare(MediaSource) still works correctly.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
littledotcommented, Oct 4, 2020

Thanks for working on caching, I appreciate the 2.12.0 changes that makes setting up a cache for SimpleExoPlayer much easier. But I’m talking about no-cache players, and I think you might be confusing Progressive vs Adaptive streams. 😃

Behavior <2.12.0, with no cache configured: Progressive streaming, using .prepare(MedisSource) -> only downloads once DASH, HLS using .prepare(MediaSource) -> downloads non-stop (I understand the difference and expect that this is normal)

Behavior >= 2.12.0, with no cache configured: Progressive streaming, using .setMediaItem(MediaItem) & .prepare() -> downloads non-stop Progressive streaming, using .prepare(MediaSource) -> only downloads once DASH, HLS using .prepare(MediaSource) -> downloads non-stop

But let me spell out why I think this is a big deal. 😃

.setMediaItem(MediaItem) + .prepare() - a new API in 2.12.0 - is meant to deprecate .prepare(MediaSource), yet they yield radically different behaviors when dealing with Progressive media types. This is a huge foot gun for anyone thinking this might just be another minor update. Especially since the javadocs for .prepare(MediaSource) make it sound like a simple find-and-replace refactor, but there’s actually an undocumented breaking change when a Progressive media source is being passed in to .setMediaItem(MediaItem).

If this inconsistency between prepare(MS) and prepare() is the way forward, I think it should at least be called out in the Javadocs.

0reactions
marcbaechingercommented, Oct 4, 2020

Cool! I’m glad it’s working! 😃

It seems that okHttpClient does the caching (TIL). It probably caches files in a behaviour similar to a web browser (honouring cache-control, max-age headers and the like). The DefaultMediaSourceFactory that is in charge for doing the media item to media source conversion uses the DefaultDataSourceFactory that makes HTTP requests with a plain http connection which is stateless and does not cache anything.

If you want to have the media item API use okhttp, you can inject the OkHttpDataSourceFactory into the default media source factory when building your player (not compiled and tested that code below, beware, but it should work that way).

DefaultMediaSourceFactory defaultMediaSourceFactory = new DefaultMediaSourceFactory()
    .setDataSourceFactory(new OkHttpDataSourceFactory(okHttpClient, null));

SimpleExoPlayer player = new SimpleExoPlayer.Builder(context)
    .setMediaSourceFactory(defaultMediaSourceFactory)
    .build();
Read more comments on GitHub >

github_iconTop Results From Across the Web

Repeat modes in ExoPlayer - Medium
You can enable this mode with player.setRepeatMode(Player.REPEAT_MODE_ONE); . Repeat All loops the entire timeline (all windows) indefinitely.
Read more >
repeatMode | Apple Developer Documentation
The current repeat mode of the music player. ... The currently-playing media item, or the media item, within a queue, that you have...
Read more >
Exoplayer Next button not clickable when Repeat Mode is ...
This method is called every time the player is switched to a new item or the playlist is changed. You can set the...
Read more >
EAGET PLAY M18 USER MANUAL Pdf Download - ManualsLib
PLAY M18 media player pdf manual download. ... Download this manual ... press repeatedly to select speed REPEAT Select repeat mode, ONE, ALL,...
Read more >
Windows Media Player repeatedly losing songs
I downloaded an album for the first time to my Windows Media Player 11 ... to play, burn, or sync an item that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found