apache / cordova-plugin-media-capture

Apache Cordova Media Capture Plugin
https://cordova.apache.org/
Apache License 2.0
307 stars 489 forks source link

[PoC] fix(android): API 30+ capture audio #277

Open erisu opened 10 months ago

erisu commented 10 months ago

Platforms affected

android

Motivation and Context

Description

This PR will copy the recorded file into the app cache directory and return the cached file path. The file will be accessible and usable to the app.

Android might clean up the cache directory, so app developers should decide and implement what to do with the cached file. For example, move it into a persisted directory or upload it to some storage server. The developer should also handle cache cleanup.

Also, because the recording is a copy, the original recording will still exist in the recording app. App end-users will still have access to their original recording if it no longer exists on the app.

It also Declare package visibility & small refactor for MIME detection.

Testing

Checklist

erisu commented 10 months ago

@ath0mas do you have and thoughts on this implementation pattern vs #215 which you commented on in your PR to prevent audio recording crashes..

215 was another PR attempt to resolve the issue, but also currently out-dated with conflicts.

I think in the long run, it would be better if people could migrate to MediaRecorder, the web api, but it depends on platform support requirements.

MediaRecorder was supported in iOS 14.3+ and Chrome 49+.

Also for reference the current major release of Cordova-Android min sdk support is API 24 which ships Chrome 51. But iOS is where the core minimum support falls.

erisu commented 9 months ago

Few comments, and would like to test it live quickly these days. Still a doubt on addressing only the Audio case here while the Issues were often mentioning Video too ; but also true in my case too I am running current codebase without any FileProvider rework fine, up to targetSdk 32 for now and on "common" devices/ROMs.

@ath0mas I will need to test the video functionality to confirm and maybe create a separate PR for each feature (audio, video, etc.).

Someone at work recently showed me that the video-capturing functionality was working, but the audio-capturing was not.

That is why I focused only on the audio within this PR.