Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media item downloaded repeatedly when repeat mode is Player.REPEAT_MODE_ONE #979

Closed
lovegaoshi opened this issue Jan 15, 2024 · 2 comments
Closed
Assignees
Labels

Comments

@lovegaoshi
Copy link

Hi all, I'm running into an issue previously reported for exoplayer2 in 2020 with the current media3 gl demo: when I use repeat mode == Player.REPEAT_MODE_ONE, the media source is requested repeatably throughout the playback. I added in okHttpClientFactory as mentioned in the 2020 issue since it does caching, though I still saw the repeated requests.

screenshot of the repeated mediaSource requests:
image

I also attempted to add a cache factory to the exoplayer but couldnt see anything in the cache dir:
image

I'm new to android media3 and completely lost, really appreciate if anyone can point me to the right direction, could be my code is not working as intended at all? Many thanks in advance!

@marcbaechinger
Copy link
Contributor

marcbaechinger commented Jan 16, 2024

It's correct to use a CacheDataSource.Factory.

I think in the code sample you give above you are injecting a CacheDataSource.Factory into the DefaultMediaSourceFactory that then is used to build the player.

The DefaultMediaSourceFactory however is only used to create a MediaSource if you use the MediaItem based API like player.setMediaItem(mediaItem). If you use player.setMediaSource(mediaSource) as in your code above, then you need to make sure that the mediaSource argument has been created with the CacheDataSource.Factory as well.

From the code above I can't see how the source is constructed, but I think it may be that the source you set is still using a data source that is not wrapped by a CachedDataSource.

Can you check if caching work when you either use player.setMediaItem(mediaItem) or construct the media source with a CacheDataSource.Factory?

@lovegaoshi
Copy link
Author

Thanks for the reply and the clarification! Once I correctly append the UpstreamDataSourceFactory as a HttpDataSource.Factory to my cacheFactory and use my cacheFactory to construct the mediaSource, I had caching correctly functioning and no repeated source requests.

my working repo in case anyone is interested: lovegaoshi@b414f01

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants