So as the question says: I'm trying to get pagination working for Android Auto with media3, but the documentation seems to be either lacking or I can't find it.
I currently have a MediaService
that extends MediaLibraryService
class MediaService : MediaLibraryService() {
// extra code here
override fun onGetLibraryRoot(
session: MediaLibrarySession,
browser: ControllerInfo,
params: LibraryParams?
): ListenableFuture<LibraryResult<MediaItem>> {
// get root here
}
override fun onGetItem(
session: MediaLibrarySession,
browser: ControllerInfo,
mediaId: String
): ListenableFuture<LibraryResult<MediaItem>> {
// get item with id
}
override fun onGetChildren(
session: MediaLibrarySession,
browser: ControllerInfo,
parentId: String,
page: Int,
pageSize: Int,
params: LibraryParams?
): ListenableFuture<LibraryResult<ImmutableList<MediaItem>>> {
// get children of item with id
}
// extra code here
}
The pagination should be achieved with page
and pageSize
in onGetChildren
, but these are always 0
and Int.MAX_VALUE
. How do you tell Android Auto that it has to ask for different values or that it needs to paginate?
After a bit more research on the Android Auto issue tracker and after asking some questions on the Media3 Github issue tracker I have discovered that custom pagination for Android Auto is not supported due to the Driver Distraction guidelines which I think can be found here.
So based on the comment on the Android Auto issue tracker the number of items returned have to be limited since Android Auto will not send pagination information to Media3. This means that for Android Auto, page
and pageSize
arguments of onGetChildren
can be ignored.