I am learning B4A and I would like to understand more about Reflector and JavaObject.
As far as I understand so far, the following code using Reflector:
should be the same of the following that uses JavaObject (that I find more easy):
Then what is the difference between Reflector and JavaObject, if any ?
What code runs faster ?
As far as I understand so far, the following code using Reflector:
B4X:
Sub VideoFrameAtR(dir As String, f As String, ms As Long) As Bitmap
Dim r As Reflector
Dim obj As Object
Dim bmp As Bitmap
obj = r.CreateObject("android.media.MediaMetadataRetriever")
r.Target = obj
r.RunMethod2("setDataSource", File.Combine(dir, f), "java.lang.String")
bmp = r.RunMethod3("getFrameAtTime", ms*1000, "java.lang.long", 3, "java.lang.int") ' 3=OPTION_CLOSEST
Return bmp
End Sub
B4X:
Sub VideoFrameAt(dir As String, f As String, ms As Long) As Bitmap
Dim job As JavaObject
Dim bmp As Bitmap
job.InitializeNewInstance("android.media.MediaMetadataRetriever",Null)
job.RunMethod("setDataSource", Array(File.Combine(dir, f)))
bmp = job.RunMethod("getFrameAtTime", Array(ms*1000, 3))
Return bmp
End Sub
Then what is the difference between Reflector and JavaObject, if any ?
What code runs faster ?