cordova-plugin-media-capture icon indicating copy to clipboard operation
cordova-plugin-media-capture copied to clipboard

Can't access captured media on Android 11

Open inexuscore opened this issue 3 years ago • 5 comments

I'm working on a project using Ionic 6.x, Angular 12, and Capacitor 3. The media-capture plugin works fine as in I can capture audio/video files and get the MediaFile[] response. But I can't access the captured files to read their contents (as base64 or array buffer, etc.). I've tried everything I could think of, nothing works.

I'm using a Xiaomi Redmi Note 10 running Android 11. After hours wasted on this issue, I realized that this is most likely because of privacy changes introduced in Android 10+. The captured media files need to be stored in the app's cache directory or something. The fullPath returned by the plugin looks something like this:

file:///storage/emulated/0/Android/data/com.android.soundrecorder/files/filename.aac

Tried reading the file with the cordova-file plugin, the Capacitor Filesystem plugin, nothing worked. Is there a workaround? Has this been fixed? and if so when are you planning a release?

I love working with the new versions of Ionic and Capacitor but this kind of stuff is incredibly frustrating.

inexuscore avatar Jun 10 '21 02:06 inexuscore

@inexuscore I have forked a version of this plugin and have it working with ionic and capacitor - sample code with link to forked plugin - https://github.com/aaronksaunders/vue-media-capture-2

aaronksaunders avatar Jun 22 '21 02:06 aaronksaunders

Could you show your code? I'm working with Filesystem of capacitor and I didn't have any problem.

AlanRivera16 avatar Sep 14 '22 14:09 AlanRivera16

@aaronksaunders have you test it with android 11? does it work?

itshazlan avatar Dec 22 '22 09:12 itshazlan

I have same problem with my Xiaomi 13 Lite. Android 12. No problem with other android devices and android version.

hung91 avatar Nov 07 '23 10:11 hung91

@inexuscore I have forked a version of this plugin and have it working with ionic and capacitor - sample code with link to forked plugin - https://github.com/aaronksaunders/vue-media-capture-2

Thanks, @aaronksaunders, I'll try it and see if I can make it work.

inexuscore avatar Jan 19 '24 12:01 inexuscore