Android Question How to get audio file time duration?

Massy

Member
Licensed User
Longtime User
Hello, I'm using Audio library with Erel example: https://www.b4x.com/android/forum/threads/audio-library-v1-5-new-audiostreamer-object.30550/
now I want to read the time duration of the recorded file, I'm using this code but something is not working and I always get the error: setDataSource not matched. This is my code:

B4X:
Dim jo As JavaObject
     jo.InitializeNewInstance("android.media.MediaMetadataRetriever", Null)
     Dim m As Map
     m.Initialize
     jo.RunMethod("setDataSource", _
      Array As Object(File.DirRootExternal, mFileName, _
      m))
     Log(jo.RunMethod("extractMetadata", Array As Object(9))) 'duration constant

mFileName is the name given to the audio file recorded that is: 1.wav
What am I doing wrong?
Thanks for any help
Massimiliano
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Top