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

Provide cache-aware adaptive track selection #6471

Open gb103 opened 5 years ago

gb103 commented 5 years ago

[REQUIRED] Searched documentation and issues

Looked into release notes and into the issue list in Github

[REQUIRED] Question

While exoplayer is in process of HLS streaming with cache enabled, Due to its adaptive streaming property it caches different quality of chunks based on network condition. So my question is, if a song is completely cached but in different quality of chunks, is it possible to restrict the player that it should play from cache only, whatever the quality of chunk is present in the cache, irrespective of Network condition.

A full bug report captured from the device

This not about bug, but a functionality support which I need to implement in my use case.

Link to test content

For any HLS media content

tonihei commented 5 years ago

That happens automatically when you create your MediaSource with DownloadHelper.createMediaSource. Alternatively, you can do the same manually by passing in the DownloadRequest.streamKeys to MediaSource.Factory.setStreamKeys.

gb103 commented 5 years ago

@tonihei but I do not have information which quality of segments are cached e.g. Let's say MASTER file contains 4 quality index files : index_0, index_1, index_2, index_3 and Based on network fluctuations, a user who adopted for AUTO quality mode in streaming, his streaming goes like this for a media which have around 10 segments in its streaming file. -

index_0 -> segment1_0 -> segment2_0 -> segment3_0 -> index_2 ->segment3_2 ->segment4_2 -> segment5_2 ->index_3 -> segment5_3 -> segment6_3 -> segment7_3 -> segment8_3 -> segment8_0 -> segment9_0 -> segment10_0

So Now in cache enabled case, complete song is cached but in different quality, Now I want that if user play this song again it should be played by same set of segments from cache only (no network call should be made even his network is better now ) irrespective of current network conditions.

tonihei commented 5 years ago

Thanks for the clarification. The approach mentioned above only makes sense when used with a download cache where you explicitly selected a certain quality for downloading.

Unfortunately, you problem can't be solved out-of-the-box. You may be able to implement that yourself using a custom TrackSelection implementation where you only allow to select tracks that are cached, but we should also look into providing such an option in our default implementation. Marking as an enhancement.