|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
mediaRecorder.prepare(); |
|
|
mediaRecorder.prepare(); |
|
|
mediaRecorder.start(); |
|
|
mediaRecorder.start(); |
|
|
runOnUiThread(new Runnable() { |
|
|
|
|
|
|
|
|
/*runOnUiThread(new Runnable() { |
|
|
@Override |
|
|
@Override |
|
|
public void run() { |
|
|
public void run() { |
|
|
Toast.makeText(MainActivity.this, "Videoaufzeichnung gestartet", Toast.LENGTH_SHORT).show(); |
|
|
Toast.makeText(MainActivity.this, "Videoaufzeichnung gestartet", Toast.LENGTH_SHORT).show(); |
|
|
} |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
});*/ |
|
|
} catch (IOException e) { |
|
|
} catch (IOException e) { |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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() { |
|
|
audioThread = new Thread(new Runnable() { |
|
|
@Override |
|
|
@Override |
|
|
public void run() { |
|
|
public void run() { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
private void startRecording() { |
|
|
private void startRecording() { |
|
|
cache(); //Speicherort und -namen für Audio- und Video-Datei |
|
|
cache(); //Speicherort und -namen für Audio- und Video-Datei |
|
|
|
|
|
|
|
|
VideoThread(); //Videoaufzeichnungs-Thread anlegen |
|
|
VideoThread(); //Videoaufzeichnungs-Thread anlegen |
|
|
AudioThread(); //Audioaufzeichnungs-Thread anlegen |
|
|
|
|
|
|
|
|
Runnable audiotask = new AudioTask(); |
|
|
|
|
|
audioThread = new Thread(audiotask); |
|
|
|
|
|
//AudioThread(); //Audioaufzeichnungs-Thread anlegen |
|
|
|
|
|
|
|
|
//Threads starten |
|
|
//Threads starten |
|
|
videoThread.start(); |
|
|
videoThread.start(); |