-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[PR offer] Remove an index range in ConcatenatingMediaSource #4542
Comments
Sounds like something that would be useful. @tonihei - Any thoughts? |
Yes, definitely! PRs are always welcome. The general approach you describe sounds correct and such a method could be useful for other people as well. |
Great. Could you share some info on the testing side? We had no chance to look at that yet, it was an experimental implementation after all. We noticed ConcatenatingMediaSourceTest.java is quite a long one. Have you got any suggestion on what/where to add to test such a feature? Thanks |
Yes, tests would need to be added to this file. The file is already quite long as we added a lot of tests for standard and edge case scenarios. If you find that too confusing we can easily add the test ourselves. |
Have you got any preference on behaviour w.r.t. indices and overflows? We'd prefer a more tolerant approach, like the following:
Here we're aiming at the following advantage: as a caller, I'd like to ignore the burden of checks on indices on my side, and let the library DoTheRightThing™. After remove operation (if any) is done, just invoke my callback so that I can proceed with my code (e.g. do a seek, or start/stop, add more tracks, ...). What's your take on that? Thanks |
That's seems slightly too tolerant in my opinion. :) Also, as you said above, the method signature is similar to It's unclear to me how you would end up in a situation where you pass in indices which are out of bounds. How do you determine which media source to remove if you don't even know how how many you have? |
Cool. Ok for 1. -- 4. About your doubt, well, here's a possible usage: The caller wants to remove tracks from 0 to N-1, leave N untouched, then remove tracks from N+1 to the last. When implementation is "very" tolerant, caller can just pass those indices, without checking whether N points to the very first or very last item in playlist. So basically without checking N's position w.r.t. to bounds. With a "less" tolerant implementation, caller has to still perform its own checks to avoid incurring in exceptions. |
Thanks for the explanation. Would still prefer to have the consistency with the other APIs as explained above. The example is also relatively easy to implement:
|
BTW, actual example from real code was from 1 to N-1, etc. (not from 0). My bad. |
Hi there. Here's the initial PR proposed changes. Please have a look at that and feel free to comment or request changes. Not sure about:
|
Added some comments to the PR. 1. has been addressed. 2. is probably irrelevant now and 3. can be done by us. |
We will get this merged relatively soon. Given there's a pull request already, I don't think we need to keep this issue open as well. Thanks! |
Issue description
We found ourselves in need of removing a contiguous set of tracks (i.e. playlist items) from a
ConcatenatingMediaSource
. Basically that would result in extending its public API with two methods like:Involved indices go from
fromIndex
(included) totoIndex
(excluded), following same convention as e.g.List<E>.subList()
.We put together a working implementation and started using that: things seems to work fine. If you're interested already in details here, we:
MSG_REMOVE_RANGE
message,MessageData<Integer>
passing 2nd index incustomData
,shuffleOrder.cloneAndRemove()
andremoveMediaSourceInternal()
within loopsWould you consider a PR to add this feature (of course with all required tests etc)?
Version of ExoPlayer being used
2.8.2
Please do not hesitate to ask for further details. Regards
The text was updated successfully, but these errors were encountered: