2

I was basically looking for a cordova plugin which'll allow me to navigate through device files and choose any audio file. I failed to find one that does exactly that so I 'm writing my own, currently focusing on android.

So I'm looking for way to create an audio file chooser for android with the possibility of limiting the file size. What I've tried so far is:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("audio/*");
String[] mimetypes = {"audio/3gp", "audio/AMR", "audio/mp3"};
intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);

Intent chooser = Intent.createChooser(intent, "Select File");
cordova.startActivityForResult(this, chooser, 1);

A few problems with this one, first the file type is not limited. I've tried this one amongst others to limit the display of only audio files, but I either get just mp3 files (with "audio/*") or all of them with and other combination.

Second I have no clue how to limit the size of displayed files. I thought about calculating the size once the file has been selected by the user and notifying him in case it's bigger than the allowed size. But I would really like to keep it as a last solution and see if it's possible to display files responding to size criteria.

Thanks in advance for pointing me in the right direction or telling me if it's not possible at all.

Anila
  • 1,136
  • 2
  • 18
  • 42
  • I think this can answer your question: http://stackoverflow.com/questions/7131930/get-the-file-size-in-android-sdk – Max Aug 05 '16 at 14:46
  • 1
    @Max the question you link replies to getting a file size, my question is about creating a file chooser that only shows you and let's you choose files below a certain size. – Anila Aug 05 '16 at 14:51
  • @Anila did u get an answer??? – KJEjava48 Apr 04 '17 at 09:26
  • @KJEjava48 no I didn't, sorry. I dropped the feature for now. – Anila Apr 04 '17 at 10:41

0 Answers0