Created
May 5, 2016 04:45
-
-
Save chikadance/eba690ccfb3d4bcd150de9d2f037a227 to your computer and use it in GitHub Desktop.
TestMr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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