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
Post a Comment