androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.72k stars 413 forks source link

media3 MediaLibraryService.MediaLibrarySession.Callback onSetRatting #1882

Open xiaojw123 opened 1 week ago

xiaojw123 commented 1 week ago

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

marcbaechinger commented 1 week ago

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();
    }
  }
};