use of androidx.media3.session.MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback in project media by androidx.
the class MediaSessionServiceNotificationTest method setUp.
@Before
public void setUp() throws Exception {
context = ApplicationProvider.getApplicationContext();
MediaLibrarySessionCallback sessionCallback = new MediaLibrarySessionCallback() {
@Override
public MediaSession.ConnectionResult onConnect(MediaSession session, ControllerInfo controller) {
if (player == null) {
player = new MockPlayer.Builder().setChangePlayerStateWithTransportControl(true).build();
session.setPlayer(player);
}
if (SUPPORT_APP_PACKAGE_NAME.equals(controller.getPackageName())) {
return MediaLibrarySessionCallback.super.onConnect(session, controller);
} else {
return MediaSession.ConnectionResult.reject();
}
}
};
TestServiceRegistry.getInstance().setSessionCallback(sessionCallback);
controllerTestRule.createRemoteController(new SessionToken(context, new ComponentName(context, LocalMockMediaSessionService.class)), /* waitForConnection= */
true, /* connectionHints= */
null);
}
use of androidx.media3.session.MediaLibraryService.MediaLibrarySession.MediaLibrarySessionCallback in project media by androidx.
the class MockMediaLibraryService method onGetSession.
@Override
public MediaLibrarySession onGetSession(ControllerInfo controllerInfo) {
TestServiceRegistry registry = TestServiceRegistry.getInstance();
TestServiceRegistry.OnGetSessionHandler onGetSessionHandler = registry.getOnGetSessionHandler();
if (onGetSessionHandler != null) {
return (MediaLibrarySession) onGetSessionHandler.onGetSession(controllerInfo);
}
MockPlayer player = new MockPlayer.Builder().setApplicationLooper(handler.getLooper()).build();
MediaLibrarySessionCallback callback = registry.getSessionCallback();
session = new MediaLibrarySession.Builder(MockMediaLibraryService.this, player, callback != null ? callback : new TestLibrarySessionCallback()).setId(ID).build();
return session;
}
Aggregations