use of org.odk.collect.audioclips.Clip in project collect by opendatakit.
the class AudioButtonIntegrationTest method whenTwoButtonsUseTheSameFileButDifferentClipIDs_andOneisPlayed_theyDontBothPlay.
@Test
public void whenTwoButtonsUseTheSameFileButDifferentClipIDs_andOneisPlayed_theyDontBothPlay() throws Exception {
String testFile1 = File.createTempFile("audio1", ".mp3").getAbsolutePath();
setupMediaPlayerDataSource(testFile1);
AudioButton button1 = new AudioButton(activity);
audioHelper.setAudio(button1, new Clip("clip1", testFile1));
AudioButton button2 = new AudioButton(activity);
audioHelper.setAudio(button2, new Clip("clip2", testFile1));
button2.performClick();
assertThat(button1.isPlaying(), equalTo(false));
assertThat(button2.isPlaying(), equalTo(true));
}
use of org.odk.collect.audioclips.Clip in project collect by opendatakit.
the class AudioButtonIntegrationTest method pausingActivity_releaseMediaPlayer.
@Test
public void pausingActivity_releaseMediaPlayer() throws Exception {
String testFile1 = File.createTempFile("audio1", ".mp3").getAbsolutePath();
setupMediaPlayerDataSource(testFile1);
AudioButton button = new AudioButton(activity);
audioHelper.setAudio(button, new Clip("clip1", testFile1));
activityController.pause();
assertThat(shadowOf(mediaPlayer).getState(), equalTo(ShadowMediaPlayer.State.END));
}
use of org.odk.collect.audioclips.Clip in project collect by opendatakit.
the class PromptAutoplayerTest method whenPromptHasAutoplayAudio_butNoAudioURI_andIsSelectOne_playsAllSelectAudioInOrder.
@Test
public void whenPromptHasAutoplayAudio_butNoAudioURI_andIsSelectOne_playsAllSelectAudioInOrder() {
FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_ONE).withAdditionalAttribute("autoplay", "audio").withSelectChoices(asList(new SelectChoice("1", "1"), new SelectChoice("2", "2"))).withSpecialFormSelectChoiceText(asList(new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(0).first), new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(1).first))).build();
assertThat(autoplayer.autoplayIfNeeded(prompt), equalTo(true));
verify(audioHelper).playInOrder(asList(new Clip(prompt.getIndex().toString() + " 0", REFERENCES.get(0).second), new Clip(prompt.getIndex().toString() + " 1", REFERENCES.get(1).second)));
}
use of org.odk.collect.audioclips.Clip in project collect by opendatakit.
the class PromptAutoplayerTest method whenPromptHasAutoplayAudio_andIsSelectMultiple_playsAllAudioInOrder.
@Test
public void whenPromptHasAutoplayAudio_andIsSelectMultiple_playsAllAudioInOrder() {
FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withControlType(Constants.CONTROL_SELECT_MULTI).withAudioURI(REFERENCES.get(0).first).withAdditionalAttribute("autoplay", "audio").withSelectChoices(asList(new SelectChoice("1", "1"), new SelectChoice("2", "2"))).withSpecialFormSelectChoiceText(asList(new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(1).first), new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(2).first))).build();
assertThat(autoplayer.autoplayIfNeeded(prompt), equalTo(true));
verify(audioHelper).playInOrder(asList(new Clip(prompt.getIndex().toString(), REFERENCES.get(0).second), new Clip(prompt.getIndex().toString() + " 0", REFERENCES.get(1).second), new Clip(prompt.getIndex().toString() + " 1", REFERENCES.get(2).second)));
}
use of org.odk.collect.audioclips.Clip in project collect by opendatakit.
the class PromptAutoplayerTest method whenPromptHasAutoplayAudio_withDifferentCapitalization_playsAudio.
@Test
public void whenPromptHasAutoplayAudio_withDifferentCapitalization_playsAudio() {
FormEntryPrompt prompt = new MockFormEntryPromptBuilder().withAudioURI(REFERENCES.get(0).first).withAdditionalAttribute("autoplay", "aUdio").build();
assertThat(autoplayer.autoplayIfNeeded(prompt), equalTo(true));
verify(audioHelper).playInOrder(asList(new Clip(prompt.getIndex().toString(), REFERENCES.get(0).second)));
}
Aggregations