use of androidx.media2.session.HeartRating in project ExoPlayer by google.
the class SessionCallbackBuilderTest method setRatingCallback_withRatingCallback_receivesRatingCallback.
@Test
public void setRatingCallback_withRatingCallback_receivesRatingCallback() throws Exception {
String testMediaId = "testRating";
Rating testRating = new HeartRating(true);
CountDownLatch latch = new CountDownLatch(1);
SessionCallbackBuilder.RatingCallback ratingCallback = (session, controller, mediaId, rating) -> {
assertThat(mediaId).isEqualTo(testMediaId);
assertThat(rating).isEqualTo(testRating);
latch.countDown();
return SessionResult.RESULT_SUCCESS;
};
try (MediaSession session = createMediaSession(sessionPlayerConnector, new SessionCallbackBuilder(context, sessionPlayerConnector).setRatingCallback(ratingCallback).build())) {
try (MediaController controller = createConnectedController(session)) {
assertSessionResultSuccess(controller.setRating(testMediaId, testRating), CONTROLLER_COMMAND_WAIT_TIME_MS);
assertThat(latch.await(0, MILLISECONDS)).isTrue();
}
}
}
Aggregations