Browse Source

Runnable test implementation

Aufzeichnung
Christian Tinz 1 year ago
parent
commit
518e207032
1 changed files with 32 additions and 5 deletions
  1. 32
    5
      app/src/main/java/com/example/greenwatch/MainActivity.java

+ 32
- 5
app/src/main/java/com/example/greenwatch/MainActivity.java View File

@@ -116,12 +116,12 @@ public class MainActivity extends AppCompatActivity {
try {
mediaRecorder.prepare();
mediaRecorder.start();
runOnUiThread(new Runnable() {
/*runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "Videoaufzeichnung gestartet", Toast.LENGTH_SHORT).show();
}
});
});*/
} catch (IOException e) {
e.printStackTrace();
}
@@ -129,7 +129,32 @@ public class MainActivity extends AppCompatActivity {
});
}

private void AudioThread(){
public class AudioTask implements Runnable {

@Override
public void run() {
audioRecorder = new MediaRecorder();
audioRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
audioRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
audioRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
audioRecorder.setOutputFile(audioPath);

try {
audioRecorder.prepare();
audioRecorder.start();
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainActivity.this, "Audioaufzeichnung gestartet", Toast.LENGTH_SHORT).show();
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
}

/*private void AudioThread(){
audioThread = new Thread(new Runnable() {
@Override
public void run() {
@@ -153,13 +178,15 @@ public class MainActivity extends AppCompatActivity {
}
}
});
}
}*/

private void startRecording() {
cache(); //Speicherort und -namen für Audio- und Video-Datei

VideoThread(); //Videoaufzeichnungs-Thread anlegen
AudioThread(); //Audioaufzeichnungs-Thread anlegen
Runnable audiotask = new AudioTask();
audioThread = new Thread(audiotask);
//AudioThread(); //Audioaufzeichnungs-Thread anlegen

//Threads starten
videoThread.start();

Loading…
Cancel
Save