You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "breautek (via GitHub)" <gi...@apache.org> on 2023/08/09 17:44:53 UTC

[GitHub] [cordova-plugin-media-capture] breautek commented on a diff in pull request #277: [PoC] fix(android): API 30+ capture audio

breautek commented on code in PR #277:
URL: https://github.com/apache/cordova-plugin-media-capture/pull/277#discussion_r1288966342


##########
src/android/Capture.java:
##########
@@ -377,20 +381,54 @@ else if (resultCode == Activity.RESULT_CANCELED) {
         }
     }
 
-
     public void onAudioActivityResult(Request req, Intent intent) {
-        // Get the uri of the audio clip
-        Uri data = intent.getData();
-        if (data == null) {
-            pendingRequests.resolveWithFailure(req, createErrorObject(CAPTURE_NO_MEDIA_FILES, "Error: data is null"));
-            return;
+        Uri srcContentUri = intent.getData();
+
+        // Get file name
+        String srcContentUriString = srcContentUri.toString();
+        String fileName = srcContentUriString.substring(srcContentUriString.lastIndexOf('/') + 1);
+
+        // Create dest file path
+        String tempRoot = cordova.getActivity().getCacheDir().getAbsolutePath();
+        String destFile = tempRoot + "/" + fileName;
+
+        // Create dest file
+        File tmpRootFile = new File(destFile);
+
+        try {
+            // If file exists

Review Comment:
   > as I see other capture types have runtime exception throwing in some cases
   
   I think all `RuntimeException` usages have been removed now.
   
   > Again maybe keep some sort of common pattern and not go for a new structure only for Audio?
   
   This PR is only touching the Audio aspect. I foresee further PRs being created to address video and image capture.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org