这是indexloc提供的服务,不要输入任何密码
Skip to content

How does Android Auto pagination work with media3? #189

@gookman

Description

@gookman

So as the tittle says, I'm looking for information about how pagination works in Android Auto and media3. I haven't been able to find documentation on the topic so maybe someone from the team can answer directly.

I currently have a MediaService that extends MediaLibraryService and implements all the methods needed by Android Auto to fetch data

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
}

I can see that onGetChildren has both page and pageSize attributes, but when testing (with the desktop head unit) these values are always 0 and Int.MAX_VALUE. I have looked into the source code and see that this is all handled in MediaLibraryServiceLegacyStub and these arguments are retrieved with MediaBrowserCompat.EXTRA_PAGE and MediaBrowserCompat.EXTRA_PAGE_SIZE. It looks like in my case in onLoadChildren the options argument is always null. I'm not sure where these options are coming from.

So my question is where are page and pageSize coming from and how can they be controlled (if they can be controlled)? Is this something that Android Auto decides? Is there some configuration option that I am missing?

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions