knight9999 opened a new pull request #168: CB-12849: check state in destroy and move file by stream URL: https://github.com/apache/cordova-plugin-media/pull/168 <!-- Please make sure the checklist boxes are all checked before submitting the PR. The checklist is intended as a quick reference, for complete details please see our Contributor Guidelines: http://cordova.apache.org/contribute/contribute_guidelines.html Thanks! --> ### Platforms affected android ### What does this PR do? Resolving recording audio issue. 1. File.renameTo method used in AudioPlayer.java can not move file across partitions. Then I developed copying the file by using i/o stream when renameTo failing. 2. media.stopRecord() in JS calls stopRecording in Java, However media.release() in JS also calls stopRecording in Java via destroy method. The second call of stopRecording overrides the audio file with empty. This PR prevents the duplicated call of stopRecording. ### What testing has been done on this change? sample code is ``` var fileName = "test.aac"; var myMedia = {}; var myStatus = null; function recordMedia(){ myMedia = new Media(cordova.file.dataDirectory + fileName, function (msg) { console.log("Success:", msg); }, function (e) { console.error("Error:", e); myMedia.release(); myStatus = Media.MEDIA_NONE; }, function (status) { console.info("Status:", status); myStatus = status; if (status == Media.MEDIA_STOPPED) { myMedia.release(); myStatus = Media.MEDIA_NONE; } }); myMedia.startRecord(); } function stopMedia () { if (myStatus != Media.MEDIA_NONE) { if (myStatus != Media.MEDIA_STOPPED) { myMedia.stopRecord(); } } } ``` ### Checklist - [x] [Reported an issue](http://cordova.apache.org/contribute/issues.html) in the JIRA database - [x] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected. - [x] Added automated test coverage as appropriate for this change.
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
