Hi, I am making a simple program with which the user records videos, photos and audios. Then he can watch them or play them back.
I save all the files in a local directory of the program.
In all cases I use the default program that the user has installed on his device.
With videos and photos, so far, I have not had any problem, however with audio files it works on some devices and not on others.
At first I did it this way (code summary):
Then, as it did not work on many devices, I tried this other way:
In this last way it also works in some yes and in others no, specifically it calls the default program but then I don't know how to access the directory where it has saved the audio because I don't know with which name it has saved it.
On other devices it works correctly.
In short, my question is how can you call any default program, which uses any audio format, and then I can access the saved file to move it to the local directory of my program.
Thank you very much.
I save all the files in a local directory of the program.
In all cases I use the default program that the user has installed on his device.
With videos and photos, so far, I have not had any problem, however with audio files it works on some devices and not on others.
At first I did it this way (code summary):
B4X:
Sub Class_Globals
Dim aud As AudioRecordApp
Sub Audio
Dim cTestAudio As String = "test.ogg"
aud.Record( ShCode.cDirShared, cTestAudio )
Wait For aud_RecordComplete (Success As Boolean)
If Success Then ' copy to local directory
Wait For (File.CopyAsync(ShCode.cDirShared,cTestAudio,ShCode.cDirMedia,cTestAudio)) complete (Success As Boolean)
If Success Then ' delete from shared
File.Delete(ShCode.cDirShared,cTestAudio)
End If
End If
End Sub
Then, as it did not work on many devices, I tried this other way:
B4X:
Sub Audio
Dim cTestAudio As String = "test.ogg"
Dim in As Intent
in.Initialize("android.provider.MediaStore.RECORD_SOUND", "")
StartActivityForResult(in)
Wait For ion_Event (MethodName As String, Args() As Object)
Dim iRes As Int = Args(0)
If iRes=(-1) Then ' ok
Dim in As Intent = Args(1)
Dim uri As String = in.GetData
Wait For (File.CopyAsync("ContentDir",uri, ShCode.cDirMedia, cTestAudio)) Complete (Success As Boolean)
If Success Then ' delete from system dir
File.Delete("ContentDir",uri)
End If
End If
End Sub
Sub StartActivityForResult(i As Intent)
Dim jo As JavaObject = Me
jo = jo.RunMethod("getBA", Null)
ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
jo.RunMethod("startActivityForResult", Array(ion, i))
End Sub
In this last way it also works in some yes and in others no, specifically it calls the default program but then I don't know how to access the directory where it has saved the audio because I don't know with which name it has saved it.
On other devices it works correctly.
In short, my question is how can you call any default program, which uses any audio format, and then I can access the saved file to move it to the local directory of my program.
Thank you very much.