Android Question How to get audio file time duration?

Discussion in 'Android Questions' started by Massy, Jun 2, 2015.

  1. Massy

    Massy Member Licensed User

    Hello, I'm using Audio library with Erel example:
    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:

    Dim jo As JavaObject
    Dim m As Map
    "setDataSource", _
    Array As Object(File.DirRootExternal, mFileName, _
    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
    Last edited: Jun 2, 2015
  2. Erel

    Erel Administrator Staff Member Licensed User

    Please use [code]code here...[/code] tags when posting code.
    jo.RunMethod("setDataSource"Array (File.Combine(File.DirRootExternal, mFileName)))
  3. Massy

    Massy Member Licensed User

    Hey! Thanks Erel, with your code I don't get error and I get a result... but for a file that is 5 seconds long I get 3942 value... how should I read it?
    Nevermind... I got it... they are millisec...
    Thanks for your help Erel you're great!
  4. DonManfred

    DonManfred Expert Licensed User

    are you sure it is really 5 seconds? I would expect it to be 3,942 seconds.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice