Android Question videoRecorder didnt work at sdk 24.

dragonguy

Active Member
Licensed User
i use this code running on sdk 24 but totally cant record video, is it i miss something?
B4X:
Sub Process_Globals
  Dim audioRecorder As AudioRecordApp
  Dim videoRecorder As VideoRecordApp
End Sub

Sub Globals
  Dim vv As VideoView
End Sub

Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
    audioRecorder.Initialize("audioRecorder")
    videoRecorder.Initialize("videoRecorder")
  End If
  vv.Initialize("vv")
  Activity.AddView(vv, 0, 0, 100%x, 100%y)
  Activity.AddMenuItem("Record Video", "RecordVideo")
  Activity.AddMenuItem("Record Audio", "RecordAudio")
  ToastMessageShow("Press on Menu button...", True)
End Sub

Sub RecordVideo_Click
  videoRecorder.Record(File.DirRootExternal, "1.mp4")
End Sub
Sub RecordAudio_Click
  audioRecorder.Record(File.DirRootExternal, "1.3gpp")
End Sub
Sub videoRecorder_RecordComplete (Success As Boolean)
  Log(Success)
  If Success Then
    vv.LoadVideo(File.DirRootExternal, "1.mp4")
    vv.Play
  End If
End Sub
Sub audioRecorder_RecordComplete (Success As Boolean)
  Log(Success)
  If Success Then
    vv.LoadVideo(File.DirRootExternal, "1.3gpp")
    vv.Play
  End If
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
i attach the small test project.
please help me.
 

Attachments

dragonguy

Active Member
Licensed User
Yes, I try to save in dirrootexternal. I have try to add the permission but still can't make it work.
B4X:
AddManifestText(
<uses-permission
  android:name="android.permission.WRITE_EXTERNAL_STORAGE"
  android:maxSdkVersion="18" />
)
 

DonManfred

Expert
Licensed User
Yes, I try to save in dirrootexternal. I have try to add the permission but still can't make it work.
No, you are NOT folowing the new runtimepermission-system... You are trying to do it the old way.

This is an optional feature. It is only relevant if android:targetSdkVersion is set to 23 or above.
If the targetSdkVersion is lower than 23 then the standard permissions system will be used on all devices including Android 6+.

Follow this tutorial: https://www.b4x.com/android/forum/threads/runtime-permissions-android-6-0-permissions.67689/
 

dragonguy

Active Member
Licensed User
Yes, I have read the post but I can't find the info about the dirrootexternal, only got
B4X:
1. Use RuntimePermissions.GetSafeDirDefaultExternal("") instead of File.DirDefaultExternal. The parameter passed is an optional subfolder that will be created under the default folder.
 

DonManfred

Expert
Licensed User
B4X:
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
B4X:
Sub Activity_PermissionResult (Permission As String, Result As Boolean)
  If Permission = rp.PERMISSION_WRITE_EXTERNAL_STORAGE Then
        If Result Then
            Log("You NOW can write to File.DirRootExternal") ' or start your recording here...
             File.WriteString(File.DirRootExternal, "String.txt", _
        "This is some string" & CRLF & "and this is another one.")
        End If
  End If
End Sub
 

DonManfred

Expert
Licensed User
With Api 23+ you need to request the permission when you first time want to write there....
Remember the answer!
You dont need to request again in another activity when you already got the permission (your remembered value)

Take in account that the user may revoke the permission at some time. You need to request again in this case.
 
Top