*/
@Test
public void testEventMediaSessionTerminated() throws InterruptedException,
IOException {
final PlayerEndpoint player = pipeline.newPlayerEndpoint(URL_SMALL)
.build();
player.connect(httpEp);
httpEp.addMediaSessionStartedListener(new MediaEventListener<MediaSessionStartedEvent>() {
@Override
public void onEvent(MediaSessionStartedEvent event) {
player.play();
}
});
AsyncResultManager<ListenerRegistration> async = new AsyncResultManager<>(
"EventListener subscription");
AsyncEventManager<MediaSessionTerminatedEvent> asyncEvent = new AsyncEventManager<>(
"MediaSessionTerminated event");
httpEp.addMediaSessionTerminatedListener(
asyncEvent.getMediaEventListener(), async.getContinuation());
async.waitForResult();
try (CloseableHttpClient httpclient = HttpClientBuilder.create()
.build()) {
// This should trigger MediaSessionStartedEvent
httpclient.execute(new HttpGet(httpEp.getUrl()));
}
asyncEvent.waitForResult();
player.release();
}