I'm facing a big problem. I use MediaMuxer to create a mp4 file. Here 's constructor of MediaMuxer:
public MediaMuxer (String path, int format)
For example:
sMediaMuxer = new MediaMuxer("/storage/emulated/0/OuputVideos/output1.mp4",OutputFormat.MUXER_OUTPUT_MPEG_4
The problem is that: Everything is ok with primary storage (internal storage), but I can not save output video to secondary SD card (external). My app runs in Lollipop devices (5.0). I read a lot of topics about working with SD card on Lollipop (for example: How to use the new SD card access API presented for Android 5.0 (Lollipop)?). All of them talk about using new Intent ACTION_OPEN_DOCUMENT_TREE to pick an output directory.
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
startActivityForResult(intent, 42);
On result of this Intent:
public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
if (resultCode == RESULT_OK) {
Uri treeUri = resultData.getData();
DocumentFile pickedDir = DocumentFile.fromTreeUri(this, treeUri);
But I don't know how to use pickedDir for MediaMuxer. Can any body help me? Thanks a lot!