use of org.odk.collect.audioclips.Clip in project collect by opendatakit.
the class SelectOneWidgetTest method whenChoicesHaveAudio_audioButtonUsesIndexAsClipID.
@Test
public void whenChoicesHaveAudio_audioButtonUsesIndexAsClipID() throws Exception {
formEntryPrompt = new MockFormEntryPromptBuilder().withIndex("i am index").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();
populateRecyclerView(getWidget());
verify(audioHelper).setAudio(any(AudioButton.class), eq(new Clip("i am index 0", REFERENCES.get(0).second)));
verify(audioHelper).setAudio(any(AudioButton.class), eq(new Clip("i am index 1", REFERENCES.get(1).second)));
}
use of org.odk.collect.audioclips.Clip in project collect by opendatakit.
the class ExAudioWidget method updatePlayerMedia.
private void updatePlayerMedia() {
if (answerFile != null) {
Clip clip = new Clip("audio:" + getFormEntryPrompt().getIndex().toString(), answerFile.getAbsolutePath());
audioPlayer.onPlayingChanged(clip.getClipID(), binding.audioPlayer.audioController::setPlaying);
audioPlayer.onPositionChanged(clip.getClipID(), binding.audioPlayer.audioController::setPosition);
binding.audioPlayer.audioController.setDuration(getDurationOfFile(clip.getURI()));
binding.audioPlayer.audioController.setListener(new AudioControllerView.Listener() {
@Override
public void onPlayClicked() {
audioPlayer.play(clip);
}
@Override
public void onPauseClicked() {
audioPlayer.pause();
}
@Override
public void onPositionChanged(Integer newPosition) {
AnalyticsUtils.logFormEvent(AnalyticsEvents.AUDIO_PLAYER_SEEK);
audioPlayer.setPosition(clip.getClipID(), newPosition);
}
@Override
public void onRemoveClicked() {
new MaterialAlertDialogBuilder(getContext()).setTitle(R.string.delete_answer_file_question).setMessage(R.string.answer_file_delete_warning).setPositiveButton(R.string.delete_answer_file, (dialog, which) -> clearAnswer()).setNegativeButton(R.string.cancel, null).show();
}
});
}
}
Aggregations