android - Determining the duration and format of an audio file -


given path (on sd card) audio file, best way of determining length of audio in milliseconds , file format (or internet media type)?

(for duration 1 use mediaplayer's getduration-method, seems slow/clumsy.)

for length of audio file:

file yourfile; mediaplayer mp = new mediaplayer(); fileinputstream fs; filedescriptor fd; fs = new fileinputstream(yourfile); fd = fs.getfd(); mp.setdatasource(fd); mp.prepare();  int length = mp.getduration(); mp.release(); 

check mimetype: https://stackoverflow.com/a/8591230/3937699


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

sql server - python to mssql encoding problem -

windows - Python Service Installation - "Could not find PythonClass entry" -