Hey,
I'm using my current Advanced Camera Library to add a Video Recorder to it.
This is my Java code:
But when executing the code, I get a java.lang.runtimeexception: start failed
Log:
I respected all guidelines from the MediaRecorder and I still don't see why it doesn't work.
I'm using my current Advanced Camera Library to add a Video Recorder to it.
This is my Java code:
B4X:
MediaRecorder m_recorder = new MediaRecorder();
/**
* Initialize the video recorder. Filename as string Duration as integer,
* Width as integer, Height as integer, FrameRate as integer. Files are
* saved on sdcard as Filename.mp4
*/
public void initRecorder(String Filename, int Duration, int Width,
int Height, int FrameRate) throws IOException {
;
m_recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
m_recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
m_recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
m_recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
m_recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
m_recorder.setOutputFile("/sdcard/" + Filename);
m_recorder.setVideoSize(Width, Height);
m_recorder.setVideoFrameRate(FrameRate);
m_recorder.setPreviewDisplay(sv.getHolder().getSurface());
m_recorder.prepare();
}
/**
* starts the video recorder.
*
*/
public void startRecorder() {
isRecording = true;
try {
m_recorder.start();
} catch (IllegalStateException e) {
e.printStackTrace();
}
}
But when executing the code, I get a java.lang.runtimeexception: start failed
Log:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
main_mnusolomode_click (java line: 1579)
java.lang.RuntimeException: start failed.
at android.media.MediaRecorder.start(Native Method)
at xvs.ACL.ACL.startRecorder(ACL.java:214)
at com.rootsoft.streamnationstudio.main._mnusolomode_click(main.java:1579)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:104)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:88)
at com.rootsoft.streamnationstudio.main$B4AMenuItemsClickListener.onMenuItemClick(main.java:117)
at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:137)
at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
at com.android.internal.view.menu.ExpandedMenuView.invokeItem(ExpandedMenuView.java:89)
at com.android.internal.view.menu.ExpandedMenuView.onItemClick(ExpandedMenuView.java:93)
at android.widget.AdapterView.performItemClick(AdapterView.java:284)
at android.widget.ListView.performItemClick(ListView.java:3518)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:1890)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3652)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: start failed.
I respected all guidelines from the MediaRecorder and I still don't see why it doesn't work.