use of androidx.test.filters.MediumTest in project ExoPlayer by google.
the class SessionPlayerConnectorTest method play_onceWithAudioResourceOnMainThread_notifiesOnPlayerStateChanged.
@Test
@MediumTest
public void play_onceWithAudioResourceOnMainThread_notifiesOnPlayerStateChanged() throws Exception {
CountDownLatch onPlayerStatePlayingLatch = new CountDownLatch(1);
InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> {
try {
TestUtils.loadResource(R.raw.audio, sessionPlayerConnector);
} catch (Exception e) {
assertWithMessage(e.getMessage()).fail();
}
AudioAttributesCompat attributes = new AudioAttributesCompat.Builder().setLegacyStreamType(AudioManager.STREAM_MUSIC).build();
sessionPlayerConnector.setAudioAttributes(attributes);
sessionPlayerConnector.registerPlayerCallback(executor, new SessionPlayer.PlayerCallback() {
@Override
public void onPlayerStateChanged(SessionPlayer player, int playerState) {
if (playerState == PLAYER_STATE_PLAYING) {
onPlayerStatePlayingLatch.countDown();
}
}
});
sessionPlayerConnector.prepare();
sessionPlayerConnector.play();
});
assertThat(onPlayerStatePlayingLatch.await(PLAYER_STATE_CHANGE_WAIT_TIME_MS, MILLISECONDS)).isTrue();
}
Aggregations