2012-04-07 9 views
5

w mojej aplikacji Nagrywam mowę, więc muszę skonfigurować mój emulator zdolny do nagrywania mowy. Mam wyszukiwane w google mam jakieś rozwiązanie, które trzeba uruchomić emulator ręcznie z opcji mediów. używam następującego cmd, ale mam błąd.Jak włączyć opcję multimediów na emulatorze Android z linią poleceń

emulator -avd Test -audio-in MIC 

Używam Androida 2.2 (Api 2.2) w systemie Windows 7. Jak włączyć opcję MIC na moim emulatorze. proszę pomóż mi.

mam następujący błąd:

>emulator -avd Test -audio-in MIC 

>unknown option: -audio-in 

please use -help for a list of valid options

Odpowiedz

9

spróbuje użyć tego przykładu:

package com.benmccann.android.hello; 

import java.io.File; 
import java.io.IOException; 

import android.media.MediaRecorder; 
import android.os.Environment; 

/** 
* @author <a href="http://www.benmccann.com">Ben McCann</a> 
*/ 

public class AudioRecorder { 

final MediaRecorder recorder = new MediaRecorder(); 
final String path; 

/** 
* Creates a new audio recording at the given path (relative to root of SD card). 
*/ 
public AudioRecorder(String path) { 
this.path = sanitizePath(path); 
} 

private String sanitizePath(String path) { 
    if (!path.startsWith("/")) { 
    path = "/" + path; 
} 
if (!path.contains(".")) { 
    path += ".3gp"; 
} 
return Environment.getExternalStorageDirectory().getAbsolutePath() + path; 
} 

/** 
* Starts a new recording. 
*/ 
public void start() throws IOException { 
    String state = android.os.Environment.getExternalStorageState(); 
    if(!state.equals(android.os.Environment.MEDIA_MOUNTED)) { 
    throw new IOException("SD Card is not mounted. It is " + state + "."); 
} 

// make sure the directory we plan to store the recording in exists 
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(); 
} 

} 

nadzieję, że to pomoże. Daj nam znać, jak to działa, lub jeśli potrzebujesz dalszej pomocy.

+0

dzięki za kodowanie mam dokładny zestaw kodowania. moje zapytanie to skonfigurowany emulator zdolny do nagrywania mowy. emulator -avd Test-audio-in MIC daje błąd. Czy na emulatorze można włączyć MIC? –

+0

w emulatorze nie mogę nagrać dźwięku –

Powiązane problemy