} protected void startRecording(String file){ if (!isRecording){ saveFile=file; recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile(this.recording); try { recorder.prepare(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } isRecording = true;
audiofile = File.createTempFile("sound", ".3gp", sampleDir); } catch (IOException e) { Log.e(TAG, "sdcard access error"); return; } recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile(audiofile.getAbsolutePath()); recorder.prepare(); recorder.start(); } public void stopRecording(View view) { startButton.setEnabled(true); stopButton.setEnabled(false); recorder.stop(); recorder.release(); addRecordingToMediaLibrary();Full Snippet Info
// Methods @Kroll.method public void start() { if (recorder == null) { recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile("/dev/null"); try { recorder.prepare(); recorder.start(); } catch (IOException e) { } } } @Kroll.methodFull Snippet Info
File directory = soundFile.getParentFile(); if (!directory.exists() && !directory.mkdirs()) { throw new IOException("Path to file could not be created."); } recorder.reset(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile(path); recorder.prepare(); recorder.start(); isRecording = true; } public void stop() throws IOException { recorder.stop(); recorder.reset(); recorder.release(); isRecording = false;Full Snippet Info
File output= new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), BASENAME); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setOutputFile(output.getAbsolutePath()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD_MR1) { recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); recorder.setAudioEncodingBitRate(160 * 1024); } else { recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); } recorder.setAudioChannels(2); try {
if (!directory.exists() && !directory.mkdirs()) { throw new IOException("Path to file could not be created."); } setPath(path); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile(path); recorder.prepare(); recorder.start(); } public void setPath(String s) { try { File f = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/rpath.txt"); f.delete(); f.createNewFile(); FileOutputStream fOut = new FileOutputStream(f); OutputStreamWriter osw = new OutputStreamWriter(fOut);Full Snippet Info
// ファイル名 String name = System.currentTimeMillis() + ".3gp"; // 出力ファイルのパス String path = new File(appDir, name).getAbsolutePath(); mRecorder = new MediaRecorder(); // 入力ソースにマイクを指定 mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); // 出力フォーマットに3gpを指定 mRecorder.setOutputFormat( MediaRecorder.OutputFormat.THREE_GPP); // 音声エンコーダにAMRを指定 mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); // 出力ファイルのパスを指定 mRecorder.setOutputFile(path); try { // 準備して mRecorder.prepare(); // 録音スタート! mRecorder.start();
setError(SDCARD_ACCESS_ERROR); return; } } mRecorder = new MediaRecorder(); mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mRecorder.setOutputFormat(outputfileformat); mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); mRecorder.setOutputFile(mSampleFile.getAbsolutePath()); // Handle IOException try { mRecorder.prepare(); } catch(IOException exception) { setError(INTERNAL_ERROR); mRecorder.reset(); mRecorder.release(); mRecorder = null; return;
// Use a filedescriptor instead of direct file // This will enable easy transition to sockets later mFileOut = new FileOutputStream(mFileName); mFD = mFileOut.getFD(); mRecorder = new MediaRecorder(); mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); mRecorder.setOutputFile(mFD); mRecorder.prepare(); mRecorder.start(); } private void stopRecording() throws IllegalArgumentException, IllegalStateException, IOException { mRecorder.stop(); mRecorder.release(); mRecorder = null; mFileOut.close(); mFileOut = null;Full Snippet Info
File directory = new File(path).getParentFile(); if (!directory.exists() && !directory.mkdirs()) { throw new IOException("Path to file could not be created."); } recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile(path); recorder.prepare(); recorder.start(); } /** * Stops a recording that has been previously started. */ public void stop() throws IOException { recorder.stop(); recorder.release(); }Full Snippet Info