Android Question Class module - Create MediaRecorder lib with reflection?

Jim Brown

Active Member
Licensed User
Hi folks,
I want to write a library for MediaRecorder and my plan is to use a class module and Reflection.
While I know that RSVideoRecorder libray exists it is lacking a fundamental command.
Also, I want my app to trigger recording directly and not jump out of the application so the VideoRecordApp option from the audio library is also a non-starter.

Problem is, I don't know how to properly get started. If anyone can set the ball rolling in terms of initialising then I should be able to pick up the rest.

MediaRecorder library
http://developer.android.com/reference/android/media/MediaRecorder.html

My initial tests are failing, with a "java.lang.RuntimeException: setAudioSource failed."

Also, I don't know how call setCamera (Camera c)
http://developer.android.com/refere...order.html#setCamera(android.hardware.Camera)

The docs indicate that I should use Camera2 but looking around I assume this is not yet supported in B4a?
http://developer.android.com/reference/android/hardware/camera2/package-summary.html

A basic snippet of my code so far. I am thinking of using the CameraEx library as a reference and bringing MediaRecorder into it.

B4X:
Sub Class_Globals
   Private r As Reflector
   Private target As Object
   Private event As String
   Private mr As Object
End Sub

Public Sub Initialize (Panel1 As Panel, TargetModule As Object, EventName As String)
    r.target=mr
    mr=r.CreateObject("android.media.MediaRecorder")
End Sub

Public Sub SetAudioSource(source As Int)
    r.target=mr
    r.RunMethod2("setAudioSource",source,"java.lang.int")
End Sub
 

Jim Brown

Active Member
Licensed User
Hi Mashiane, sorry I have not touched b4a for a while. When I get a chance I'll look at what I did before.
 
Upvote 0
Top