Thema: Delphi XE5 Firemonkey

Einzelnen Beitrag anzeigen

sdean

Registriert seit: 5. Dez 2009
64 Beiträge
 
#1

XE5 Firemonkey

  Alt 10. Feb 2014, 22:38
Hello please how can we convert this piece of code from java to FMX

Code:
public class SoundRecordingExample2 extends Activity {
        private static final int RECORDER_BPP = 16;
        private static final String AUDIO_RECORDER_FILE_EXT_WAV = ".wav";
        private static final String AUDIO_RECORDER_FOLDER = "AudioRecorder";
        private static final String AUDIO_RECORDER_TEMP_FILE = "record_temp.raw";
        private static final int RECORDER_SAMPLERATE = 44100;
        private static final int RECORDER_CHANNELS = AudioFormat.CHANNEL_IN_STEREO;
        private static final int RECORDER_AUDIO_ENCODING = AudioFormat.ENCODING_PCM_16BIT;
         
        private AudioRecord recorder = null;
        private int bufferSize = 0;
        private Thread recordingThread = null;
        private boolean isRecording = false;
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
         
        setButtonHandlers();
        enableButtons(false);
         
        bufferSize = AudioRecord.getMinBufferSize(8000,
                AudioFormat.CHANNEL_CONFIGURATION_MONO,
                AudioFormat.ENCODING_PCM_16BIT);
    }

 private void startRecording(){
                recorder = new AudioRecord(MediaRecorder.AudioSource.MIC,
                                                RECORDER_SAMPLERATE, RECORDER_CHANNELS,RECORDER_AUDIO_ENCODING, bufferSize);
                 
                int i = recorder.getState();
                if(i==1)
                    recorder.startRecording();
                 
                isRecording = true;
                 
                recordingThread = new Thread(new Runnable() {
                         
                        @Override
                        public void run() {
                                writeAudioDataToFile();
                        }
                },"AudioRecorder Thread");
                 
                recordingThread.start();
        }
what i did is :

Delphi-Quellcode:
uses ..
,Androidapi.JNI.Media;

private
    { Private declarations }
    AudioRecord:TJAudioRecord;
    bufferSize:Integer;
    isRecording:boolean;

     procedure Init();
     procedure startRecording();
  public
    { Public declarations }

  end;

procedure TForm1.Init();
begin
bufferSize:=0;
isRecording := false;

AudioRecord:=TJAudioRecord.Create;

bufferSize:=AudioRecord.JavaClass.getMinBufferSize(8000,
                TJAudioFormat.JavaClass.CHANNEL_CONFIGURATION_MONO,
                TJAudioFormat.JavaClass.ENCODING_PCM_16BIT);

end;
procedure TForm.startRecording;
var
i:Integer;
begin

 AudioRecord:=TJAudioRecord.JavaClass.init;

 {
here how can i convert this procedure :
private void startRecording(){
  }


end;
i really need all your help
  Mit Zitat antworten Zitat