Skip to content

Instantly share code, notes, and snippets.

@chikadance
Created May 5, 2016 04:45
Show Gist options
  • Save chikadance/eba690ccfb3d4bcd150de9d2f037a227 to your computer and use it in GitHub Desktop.
Save chikadance/eba690ccfb3d4bcd150de9d2f037a227 to your computer and use it in GitHub Desktop.
TestMr
package ro.rotry;
import android.media.MediaRecorder;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import java.io.IOException;
public class TestMr extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_mr);
MediaRecorder recorder = new MediaRecorder();
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setOutputFile(getFilesDir() + "/try.mp4");
try {
recorder.prepare();
} catch (IOException e) {
throw new RuntimeException(e);
}
recorder.start(); // Recording is now started
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
recorder.stop();
recorder.reset(); // You can reuse the object by going back to setAudioSource() step
recorder.release(); // Now the object cannot be reused
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment