Android Question AndroidVideoCapture: Null recorder

peacemaker

Well-Known Member
Licensed User
HI, All

I'm trying to play with the video recording lib https://www.b4x.com/android/forum/t...d-in-b4a-6-jan-new-lib-files-in-post-48.60859.

Sample is working OK. But when i try to make my simplest sample

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("1")
 
    avc1.MaximimDuration = 1000 * 60 * 0.5
    avc1.MaximumFileSize = 15000000
 
    avc1.MaximumDurationReachedToastMessage = "Спасибо, максимальная длительность записи достигнута."       'added 4 Dec 2015 - set your own toast message when Max Dur is reached during recording
    avc1.MaximumFileSizeReachedToastMessage = "Спасибо, максимальный размер файла записи достигнут."      'added 4 Dec 2015 - set your own toast message when Max Files Size is reached during recording
 
    'The video files will be stored in folder /sdcard/Videos/ of your device.
    'Add code to create this folder if the folder does not exist or else just create it manually
    avc1.VideoName = Application.LabelName & "_"        'amended 4 Dec 2015 - the captured video will now be stored as "video1_yyyyMMdd_HHmmss.MP4"
    'i.e a date/time stamp will de added/appended to the video name
 
    avc1.StopCameraOnMaxSizeDuration = True             'added 30 Nov 2015
    avc1.ShowToastMessages = True                       'added 30 Nov 2015
 
'    avc1.VideoFolderName = "MyVideoFolder"              'added 4 Dec 2015 (it will make a folder called MyVideoFolder in the root directory of your device and store the videos in that folder
    avc1.VideoFolderName = "/" & Application.LabelName     'added 4 Dec 2015 (it will make a tree of folder called MyVideoFolder/Videos in the root directory of your device and store the videos in the Videos sub folder
 
    avc1.AddTimeStampToFileName = True


in my separate project - the first starting (avc1.setStartStopRecording) kills the app with error:

B4X:
has flash = true
** Activity (main) Resume **
Error occurred on line: 0 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.media.MediaRecorder.start()' on a null object reference
    at videowrapper.videoWrapper.setStartStopRecording(videoWrapper.java:295)
    at peacemaker.videothanks.main._butstart_click(main.java:529)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:6897)
    at android.widget.TextView.performClick(TextView.java:12693)
    at android.view.View$PerformClick.run(View.java:26101)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6944)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy (ignored)**
** Service (starter) Destroy (ignored)**

The lib shows for a second:
upload_2019-3-19_17-46-33.png

"Fail in prepareMediaRecorder".

Runtime permissions to PERMISSION_CAMERA and PERMISSION_RECORD_AUDIO are OK, and manifest also.

But the author sample is working on the same phone !!!111 I do not understand what the trouble is...
 
Last edited:

peacemaker

Well-Known Member
Licensed User
SOLVED: 3 permissions are required, PERMISSION_CAMERA and PERMISSION_RECORD_AUDIO and PERMISSION_WRITE_EXTERNAL_STORAGE
 
Top