Android Question How to convert the following Java code with JavaObject ?

avacondios

Active Member
Licensed User
Longtime User
Hi, I am trying to record a video using the existing RsVideoRecord library, but it fails to record the video. I found the following java code and I need your help, to convert it to B4A using JavaObject.

The code is the following :

B4X:
mediaRecorder = new MediaRecorder();
// mCamera will get it from Erel's Camera library ....
mediaRecorder.setCamera(mCamera);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
mediaRecorder.setMaxDuration(-1);
mediaRecorder.setOutputFile(fileToSave.getPath()); // your file
mediaRecorder.setVideoFrameRate(10);//videoFramesPerSecond);
mediaRecorder.setVideoSize(320, 240); // or some other size
mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
mediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
mediaRecorder.setMaxFileSize(100000000); // size in bytes
mediaRecorder.prepare();
mediaRecorder.start();

Thanks a lot
 

avacondios

Active Member
Licensed User
Longtime User
My issue is the 1st line of the code :
mediaRecorder = new MediaRecorder

How can I to convert it using JavaObjects ? For the rest commands, I can call the RunMethod from JavaObjects. Until now, I am trying to execute the following code :

B4X:
Dim obj As JavaObject
obj.InitializeStatic("android.media.MediaRecorder")
Dim mMedia As JavaObject = obj.InitializeNewInstance("MediaRecorder", Null)

but I am getting java.lang.ClassNotFoundException: java$lang$MediaRecorder

Any help ?
 
Upvote 0
Top