You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
Calling media3.session.MediaController.setMediaItems(List mediaItems) can cause an IndexOutOfBoundsException when the input list is smaller than the current timeline & the current seek position is greater than the size of the new media items.
We're using the '1.0.0-alpha03' version of Media3, a snapshot build of a105d03
Steps to reproduce:
set timeline to contain 4 media items: MediaController.setMediaItems(<List of 4 Media Items>)
seek to the final media item: MediaController.seekTo(3, C.TIME_UNSET))
Then try setting timeline to contain less than 4 new media items: MediaController.setMediaItems(<List of 3 or less new Items>)
Result:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: , PID: 9895
java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
at java.util.ArrayList.get(ArrayList.java:437)
at androidx.media3.session.MediaControllerImplBase.setMediaItemsInternal(MediaControllerImplBase.java:1887)
at androidx.media3.session.MediaControllerImplBase.setMediaItems(MediaControllerImplBase.java:888)
at androidx.media3.session.MediaController.setMediaItems(MediaController.java:942)
...
Cause:
In MediaControllerImplBase.java line 891, setMediaItemsInternal is called with resetToDefaultPosition as false and startIndex as C.INDEX_UNSET. This causes the start index for the newPositionInfo to be set to the current player index (MediaControllerImplBase.java line 1848), which will be out of bounds for the new, smaller list of media items.
Suggested fix:
I might just be using the function incorrectly, but it looks like the resetToDefaultPosition parameter in MediaControllerImplBase.java line 891 should just be true instead of false. This is in line with the function description in MediaController.java & avoids this pathway.
The text was updated successfully, but these errors were encountered:
Thanks for reporting, we'll provide a fix for this.
but it looks like the resetToDefaultPosition parameter in MediaControllerImplBase.java line 891 should just be true instead of false. This is in line with the function description in MediaController.java & avoids this pathway.
That's correct, this value should be true and the method should also handle the case when the current index is no longer in the allowed range even if resetToDefaultPosition is false.
Hi,
Calling media3.session.MediaController.setMediaItems(List mediaItems) can cause an IndexOutOfBoundsException when the input list is smaller than the current timeline & the current seek position is greater than the size of the new media items.
We're using the '1.0.0-alpha03' version of Media3, a snapshot build of a105d03
Steps to reproduce:
Result:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: , PID: 9895
java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
at java.util.ArrayList.get(ArrayList.java:437)
at androidx.media3.session.MediaControllerImplBase.setMediaItemsInternal(MediaControllerImplBase.java:1887)
at androidx.media3.session.MediaControllerImplBase.setMediaItems(MediaControllerImplBase.java:888)
at androidx.media3.session.MediaController.setMediaItems(MediaController.java:942)
...
Cause:
In MediaControllerImplBase.java line 891, setMediaItemsInternal is called with resetToDefaultPosition as false and startIndex as C.INDEX_UNSET. This causes the start index for the newPositionInfo to be set to the current player index (MediaControllerImplBase.java line 1848), which will be out of bounds for the new, smaller list of media items.
Suggested fix:
I might just be using the function incorrectly, but it looks like the resetToDefaultPosition parameter in MediaControllerImplBase.java line 891 should just be true instead of false. This is in line with the function description in MediaController.java & avoids this pathway.
The text was updated successfully, but these errors were encountered: