Search in sources :

Example 1 with AudioControllerView

use of org.odk.collect.android.audio.AudioControllerView in project collect by opendatakit.

the class AudioWidgetTest method afterSetBinaryData_showsDurationOfAudio.

@Test
public void afterSetBinaryData_showsDurationOfAudio() throws Exception {
    FormEntryPrompt prompt = promptWithAnswer(null);
    File answerFile = questionMediaManager.addAnswerFile(File.createTempFile("blah", ".mp3"));
    Clip expectedClip = getExpectedClip(prompt, answerFile.getName());
    setupMediaPlayerDataSource(expectedClip.getURI(), 322450);
    AudioWidget widget = createWidget(prompt);
    widget.setData(answerFile);
    AudioControllerView audioController = widget.binding.audioPlayer.audioController;
    assertThat(audioController.binding.totalDuration.getText().toString(), is("05:22"));
}
Also used : Clip(org.odk.collect.audioclips.Clip) FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) AudioControllerView(org.odk.collect.android.audio.AudioControllerView) File(java.io.File) Test(org.junit.Test)

Example 2 with AudioControllerView

use of org.odk.collect.android.audio.AudioControllerView in project collect by opendatakit.

the class AudioWidgetTest method afterSetBinaryData_whenPositionOfClipChanges_updatesPosition.

@Test
public void afterSetBinaryData_whenPositionOfClipChanges_updatesPosition() throws Exception {
    FormEntryPrompt prompt = promptWithAnswer(null);
    File answerFile = questionMediaManager.addAnswerFile(File.createTempFile("blah", ".mp3"));
    Clip expectedClip = getExpectedClip(prompt, answerFile.getName());
    setupMediaPlayerDataSource(expectedClip.getURI(), 322450);
    AudioWidget widget = createWidget(prompt);
    widget.setData(answerFile);
    AudioControllerView audioController = widget.binding.audioPlayer.audioController;
    assertThat(audioController.binding.currentDuration.getText().toString(), is("00:00"));
    audioPlayer.setPosition(expectedClip.getClipID(), 42000);
    assertThat(audioController.binding.currentDuration.getText().toString(), is("00:42"));
}
Also used : Clip(org.odk.collect.audioclips.Clip) FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) AudioControllerView(org.odk.collect.android.audio.AudioControllerView) File(java.io.File) Test(org.junit.Test)

Example 3 with AudioControllerView

use of org.odk.collect.android.audio.AudioControllerView in project collect by opendatakit.

the class AudioWidgetTest method afterSetBinaryData_clickingPlayAndPause_playsAndPausesAudio.

@Test
public void afterSetBinaryData_clickingPlayAndPause_playsAndPausesAudio() throws Exception {
    FormEntryPrompt prompt = promptWithAnswer(null);
    AudioWidget widget = createWidget(prompt);
    File answerFile = questionMediaManager.addAnswerFile(File.createTempFile("blah", ".mp3"));
    Clip expectedClip = getExpectedClip(prompt, answerFile.getName());
    widget.setData(answerFile);
    AudioControllerView audioController = widget.binding.audioPlayer.audioController;
    assertThat(audioController.getVisibility(), is(VISIBLE));
    audioController.binding.play.performClick();
    assertThat(audioPlayer.getCurrentClip(), is(expectedClip));
    audioController.binding.play.performClick();
    assertThat(audioPlayer.getCurrentClip(), is(expectedClip));
    assertThat(audioPlayer.isPaused(), is(true));
    audioController.binding.play.performClick();
    assertThat(audioPlayer.getCurrentClip(), is(expectedClip));
    assertThat(audioPlayer.isPaused(), is(false));
}
Also used : Clip(org.odk.collect.audioclips.Clip) FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) AudioControllerView(org.odk.collect.android.audio.AudioControllerView) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)3 FormEntryPrompt (org.javarosa.form.api.FormEntryPrompt)3 Test (org.junit.Test)3 AudioControllerView (org.odk.collect.android.audio.AudioControllerView)3 Clip (org.odk.collect.audioclips.Clip)3