[ 
https://issues.apache.org/jira/browse/CB-12849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16517708#comment-16517708
 ] 

ASF GitHub Bot commented on CB-12849:
-------------------------------------

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:
us...@infra.apache.org


> Media Plugin: Saves file not in indicated directory
> ---------------------------------------------------
>
>                 Key: CB-12849
>                 URL: https://issues.apache.org/jira/browse/CB-12849
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-android, cordova-plugin-media
>    Affects Versions: 6.5.0
>         Environment: Device model: Nexus 5X
>  Android version of device: 8.1.0
>  Platform version: 7.1.0
>  Cordova version: 8.0.0
>  Cordova plugin media version: 5.0.1
>            Reporter: Florian Pechwitz
>            Priority: Major
>              Labels: cordova-plugin-media
>
> I tried to build an application which records, stops the recording and then 
> plays the recorded audio.
> The recording works fine but if I try to play the recorded audio I get error 
> code 1. I found out that the recorded audio file was not in the directory but 
> in a totally different directory 
> (/storage/emulated/0/(tmprecording-1495618229386.3gp) with a different file 
> name (tmprecording-1495618229386.3gp) and a different media type (video/3gpp) 
> as indicated.
> I created a repo with a example application for this issue: 
> https://github.com/Durzan666/cordova-plugin-media-demo



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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

Reply via email to