Skip to content
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

media3 MediaLibraryService.MediaLibrarySession.Callback onSetRatting #1882

Open
1 task done
xiaojw123 opened this issue Nov 14, 2024 · 1 comment
Open
1 task done

Comments

@xiaojw123
Copy link

Version

Media3 main branch

More version details

No response

Devices that reproduce the issue

Porsche Car AutoMotive

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

1.Car Launcher Media Card 2.click collection button

Expected result

MediaLibraryService.MediaLibrarySession.Callback onSetRatting should be invoked , the i can handle the Launcher Media Ratting Status

Actual result

MediaLibraryService.MediaLibrarySession.Callback onSetRatting no invoke

Media


Bug Report

  • You will email the zip file produced by adb bugreport to [email protected] after filing this issue.
@marcbaechinger
Copy link
Contributor

Thanks for your report.

I'm not exactly sure how the collection button is related to sending a rating. However, when I test sending a rating from a legacy MediaControllerCompat I receive this callback on the Media3 MediaSession.Callback side as expected (please see below for details).

Like I said, I'm not completely familiar with the details on the client side. However, when a client send a rating then it seems to work on the library side.

Can you double check this is working as intended on the app side? Are you seeing a difference from your implementation with the compat library to how it behaves with Media3? Please add some more details if you think this is a problem on the library side. From the above testin, I'd say media3 handles such a rating as expected.


When I do a test case to send a rating with a legacy controller like so:

controllerCompat
        .getTransportControls()
        .setRating(RatingCompat.newThumbRating(true), new Bundle());

then I receive the callback on the media session end:

@Override
public ListenableFuture<SessionResult> onSetRating(
    MediaSession session,
    ControllerInfo controller,
    String mediaId,
    Rating rating) {
  
 setMediaMetadata(new MediaMetadata.Builder()
          .setUserRating(rating)
          .setDisplayTitle("rating arrived")
          .build());
  notifyMediaMetadataChanged();
  return immediateFuture(new SessionResult(SessionResult.RESULT_SUCCESS));
}

which then triggers an update of the metadata callback that the controller can receive:

new MediaControllerCompat.Callback() {
  @Override
  public void onMetadataChanged(MediaMetadataCompat metadata) {
    RatingCompat rating = metadata.getRating(METADATA_KEY_USER_RATING);
    if (rating != null
        && rating.isThumbUp()
        && metadata.getString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE) != null
        && metadata
            .getString(MediaMetadataCompat.METADATA_KEY_DISPLAY_TITLE)
            .equals("rating arrived")) {
      metadataLatch.countDown();
    }
  }
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants