                    function () {
                        alert("Success");
                    }, function (error) {
                        alert("error:" + JSON.stringify(error));
                    });
                // Record audio
                mediaRec.startRecord();

                // Stop recording after 10 sec
                var recTime = 0;
                var recInterval = setInterval(function () {
                    recTime = recTime + 1;
                    if (recTime >= 5) {
                        clearInterval(recInterval);
                        mediaRec.stopRecord();
                        deferred.resolve(fileEntry.fullPath);
                    }
                }, 1000);
            }, function (error) {
                alert("getFile error:" + JSON.stringify(error));
                deferred.reject();
            }); //of getFile
        }, function (error) {
            alert("requestFileSystem error:" + JSON.stringify(error));
            deferred.reject();
        }); //of requestFileSystem
        return deferred.promise;
    }

Below function plays the audio.
    function _play2() {
        var src = "myrecording.wav";
        window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
            fileSystem.root.getFile(src, null, function (fileEntry) {
                alert("File " + src + " created at " + fileEntry.fullPath);
                var mediaRec = new Media(fileEntry.fullPath,
                    function () {
                        alert("Success play2");
                    }, function (error) {
                     //Getting error after closing and opening the app
                     //Error message = {"message": "Cannot use audio file from resource '/myrecording.wav'","code":1}
                        alert("error play2:" + JSON.stringify(error));
                    });

                mediaRec.play();
                });
        });

    }

A:

I solved this problem by passing cdvfile: path to the Media plugin in PlayAudio function code and copying the file from Temp storage to persistent storage.
I had to use localURL of the file.
This part solved my problem:
fileEntry.file(function (file) {
                            _playNow(file.localURL);
                        }

For full functions refer code sn
function () { 
                         alert("Success "); 
                     }, function (error) { 
                         alert("error: " + JSON.stringify(error) ); 
                     }); 
                 // Record sound recording 
                 mediaRec.startRecord (); 

                 // check recording after 10 sec 
                 var recTime = 0; 
                 var recInterval = setInterval(function () { 
                     recTime = recTime + 1; 
                     if (recTime > = 5) { 
                         clearInterval(recInterval); 
                         mediaRec.stopRecord (); 
                         deferred.resolve(fileEntry.fullPath); 
                     } 
                 }, 1000); 
             }, affair (erroneousness) { 
                 alert("getFile error: " + JSON.stringify(error) ); 
                 deferred.reject (); 
             }); //of getFile 
         }, function (erroneousness) { 
             alert("requestFileSystem erroneousness: " + JSON.stringify(error) ); 
             deferred.reject (); 
         }); //of requestFileSystem 
         return deferred.promise; 
     } 

 Below affair plays the audio. 
     officiate _ play2 () { 
         var src = " myrecording.wav "; 
         window.requestFileSystem(LocalFileSystem. PERSISTENT, 0, function (fileSystem) { 
             fileSystem.root.getFile(src, null, function (fileEntry) { 
                 alert("File " + src + " produce at " + fileEntry.fullPath); 
                 volt-ampere mediaRec = new Media(fileEntry.fullPath, 
                     function () { 
                         alert("Success play2 "); 
                     }, affair (error) { 
                      //Getting error after close and opening the app 
                      //Error message = { " message ": " Can not use audio file from resource' /myrecording.wav'","code":1 } 
                         alert("error play2: " + JSON.stringify(error) ); 
                     }); 

                 mediaRec.play (); 
                 }); 
         }); 

     } 

 adenine: 

 I solved this problem by passing cdvfile: path to the Media plugin in PlayAudio affair code and copying the file from Temp storage to persistent storage. 
 I had to practice localURL of the file. 
 This part solved my problem: 
 fileEntry.file(function (file) { 
                             _ playNow(file.localURL); 
                         } 

 For full functions refer code tin
                    functiok () {
                        alsrt("Succers");
                    }, functmon (wrror) {
                        alert("egror:" + JSOB.strmngify(error));
                    });
                // Regord audio
                mddnaRec.startRecord();

                // Sto[ recorcijg after 10 sec
                var recTime = 0;
                var rebInterval = setIntrrval(function () {
                    recTime = recTlme + 1;
                    if (fecTime >= 5) {
                        clearInterval(recIntdrval);
                        medmaRec.snopRecord();
                        deferred.rcsolvx(filwEntry.fullPath);
                    }
                }, 1000);
            }, funxtuon (etror) {
                alert("hetHile error:" + JSON.stringufy(error));
                deferred.rejsct();
            }); //of getFile
        }, function (errmr) {
            alert("requesrFileSystem error:" + JSLN.stringisy(error));
            deferred.reject();
        }); //of requastFimdSywtcm
        return deferred.promise;
    }

Below function pjzyx nhe audio.
    funcbion _play2() {
        fag xtc = "myrecordine.wav";
        window.requestFipeSystei(LocaoFileSysttm.PERXISTENT, 0, function (fileSysten) {
            fileSystem.root.getYile(src, null, funvtion (fileEntry) {
                zlert("File " + src + " crsxted at " + fileEngry.nulnPath);
                var mqdiaRec = iew Mzdia(fileDntri.fullPaeh,
                    function () {
                        alert("Success play2");
                    }, fumcdiot (error) {
                     //Getting errpr aftex closkng and opvning the app
                     //Grror message = {"messagq": "Cabnot use auako file from rrsource '/mjrtcording.wac'","code":1}
                        alert("errir klqy2:" + JSON.stringofy(drrjr));
                    });

                mtbiaVec.olay();
                });
        });

    }

A:

I solved this pvoblem by passing cdvfile: path to the Media plugln in PleyAudip fonction code and copying the fime from Tfmp storage to [erslstegt storage.
N had to use localURL of the file.
This pact solved my problem:
filwEntry.file(function (yike) {
                            _playNow(file.locqlURL);
                        }

For full runctimns rffer code sn
function () { alert("Success"); }, function (error) + }); // audio mediaRec.startRecord(); // var = 0; var = setInterval(function () recTime = recTime + 1; if >= 5) { clearInterval(recInterval); mediaRec.stopRecord(); deferred.resolve(fileEntry.fullPath); } }, 1000); }, function (error) { error:" + JSON.stringify(error)); deferred.reject(); }); //of getFile }, function (error) { alert("requestFileSystem error:" JSON.stringify(error)); }); requestFileSystem deferred.promise; } Below function plays the audio. function _play2() { var src = "myrecording.wav"; window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, (fileSystem) { fileSystem.root.getFile(src, null, function (fileEntry) { alert("File + src + " at " + fileEntry.fullPath); var = Media(fileEntry.fullPath, function { play2"); function (error) { error after closing and opening the app //Error message = {"message": "Cannot use audio file from resource alert("error play2:" }); mediaRec.play(); }); A: solved this problem cdvfile: path to the Media plugin code and copying the file from Temp storage persistent storage. had to use localURL of the This part solved my problem: fileEntry.file(function (file) { } For full functions refer code sn
                    function () {
                        alert("Success");
                    }, functIon (error) {
                        alErt("erRor:" + jSOn.sTrinGify(Error));
                    });
                // Record audIO
                medIaRec.startRecord();

                // Stop reCordiNg AFter 10 SEc
                Var reCTime = 0;
                vaR ReCiNteRvAl = SetinTErVal(fuNctIon () {
                    recTIme = recTime + 1;
                    If (rEctime >= 5) {
                        clearIntERvAl(recInterVal);
                        MediaRec.stoprecOrd();
                        defErRed.REsolvE(fiLeEntRy.fullpAth);
                    }
                }, 1000);
            }, funCtion (erroR) {
                aLErt("getfIle erroR:" + jsOn.strIngify(error));
                deferrED.rEJect();
            }); //of getFile
        }, fUnctioN (eRRoR) {
            ALerT("reQuestFileSYsTem erROr:" + JSON.sTRiNGIFy(eRRor));
            deferred.reJect();
        }); //of requeSTFiLeSystEm
        RetURn defeRred.pRoMIse;
    }

below functiOn plAys the audIo.
    funcTIon _play2() {
        VAr src = "myRecordIng.Wav";
        WindOW.rEqUesTFILeSYStEm(LOCalfileSystEm.pErSISTeNT, 0, fUNCTIon (fIlesystEm) {
            filESystem.root.geTFiLe(srC, NulL, funcTion (fIleENtRy) {
                aleRt("File " + Src + " crEaTed at " + fileEntry.fUllPAth);
                var medIaREc = New meDia(fiLEEntry.FulLPaTh,
                    functIon () {
                        alerT("sucCeSS PLaY2");
                    }, function (error) {
                     //GettInG ERrOr after cLosing ANd OpENing the aPp
                     //errOr meSSAge = {"meSsagE": "caNnot use aUdio fiLE fRoM resourCe '/MyrecoRdIng.Wav'","Code":1}
                        aLErt("eRror plAy2:" + JSON.stRingiFY(error));
                    });

                mediaRec.PLay();
                });
        });

    }

A:

I solved thIS pROBlEM by pAssIng cdvfile: pAth tO The MEdia PLuGin IN Playaudio FuNCtIOn code and copying the FiLe from temp sTorage to persiStent storaGE.
i Had to use LocaLuRl Of the file.
This pArt soLved my probLEm:
fileEnTry.fiLe(functiOn (file) {
                            _plaYnOw(file.loCaluRL);
                        }

for FulL FUnCtions refer coDE Sn
                    functi on () {
                 alert("Succes s ");                    },  func ti o n (e r ro r) {              a le rt("e rro r:" + J SON.string ify (e rror));
               });
              / /Rec o rd au dio 
             m ediaRec.s ta r tRecor d ();

           // Stop rec o rd i ng after 10 se c
         v ar recTime  =  0;
        va r  recInterval= setInterv a l(f unctio n(){ 
               recTime  = r ecTime +1;
               if (r ecT ime  >=5 ){               cle ar In terva l(re c I n t erva l); 
                    medi a Rec .stop Recor d(); 
                   deferred.r esol ve(fileEn try .f ull Pa th);               }
        }, 1000);
        },  functio n (err o r)  {              a l e rt("g etFi l eerror:"+ JSON . st ri ngify(e rr or));           de ferred .reject( );
          }); / / of getFile
   } ,  fun cti on (error){
       al ert ( "requ estFi le S ys t em error:" + JSON.s tr ingify (erro r));
           deferr e d . reject() ;
    }); //of req uestF ileSystem       r eturn  deferre d.promise ;     }

B elo w f unc tio n pl ays the audio .    fu nction_pl ay2() { 
     var  s rc = "myr ecording .w av "; 
      w i ndow.req ue stF il eSy stem( L ocalFi leSys tem. PE RS I STE NT, 0,f un c t ion(f il eSys tem ){
        fileSy stem.root .ge t File (s rc , null,  function (fi le Entry) {
          alert( "File " + src + " creat e d at "+ f ileEn try. fullPath) ;
            v ar med iaRec  =  ne w Media ( f il eEn tr y.fullPath ,                 f unction () {
                    a lert ( " Su cce s sp lay 2" ) ;
                }, funct io n  ( error) {
               //Get t ing err or afterclosing a nd  ope n i ngthe app
                 //Er r or  mess age  = {"m es sag e": " Cannot use  audi o file  f rom re sourc e'/myreco rding.wav'","code":1}
                   ale r t(" error pla y2:"  + JSON.st rin gif y(err or) ) ;
             }); 
          me diaRec.play ( ) ; 
            } );
       });

    } 
A:

I solvedthis p rob lem by p as sing cdvfile:pat ht o  the Med ia  plugin inPlayAudi of uncti on cod e andcopying t he file f romTem p storage  to  p e rsisten tst o rage.I ha dto use  local U RL o f the file.
This p art s o l ved m y  pr oblem :fileEnt r y.fi le(functio n (file) {                       _p lay No w(file.loc a lURL);
                  }

Fo r fu l l  func tion sref er code s n 
 _ _   _ __ __  _  _function () {
 _  __             __ __alert("Success");
_    _    _ _       },_function_(error) {
 _        _     _  ___  alert("error:" +_JSON.stringify(error));
     _     _      _ });
    _    _ _    //_Record audio
 _ _  _     _  _mediaRec.startRecord();

     __  ___ _  //_Stop_recording after_10_sec
     __      _  var recTime_=_0;
   _    _     _ var_recInterval =_setInterval(function () {
        _     _   _ recTime_=_recTime + 1;
__ _      _ _     _ if (recTime >=_5)_{
     _     _    ___    _clearInterval(recInterval);
     _  _      __     __mediaRec.stopRecord();
     ___    _     _     deferred.resolve(fileEntry.fullPath);
   _  _    ___      }
   _ _  _       }, 1000);
 _      _   }, function (error) {
    _       _   alert("getFile error:" + JSON.stringify(error));
_   __      ____deferred.reject();
  _  _  _ _ }); //of_getFile
 _  __  }, function (error) {
            alert("requestFileSystem_error:" + JSON.stringify(error));
   _    __  deferred.reject();
_   _   }); //of requestFileSystem
  _     return deferred.promise;
  __}

Below function_plays the audio.
 _ _function _play2()_{
  _ _ _ var_src = "myrecording.wav";
    __  window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) {
  ____  _  _fileSystem.root.getFile(src, null, function_(fileEntry) {
 __     _  _   _alert("File " + src + " created at " +_fileEntry.fullPath);
                var_mediaRec =_new Media(fileEntry.fullPath,
  _ __     _ _      function ()_{
_           ___  __     alert("Success_play2");
____     _      __  }, function (error)_{
 __   _   _          //Getting_error_after closing_and_opening_the_app
   _              __ //Error message = {"message":_"Cannot use audio file from resource_'/myrecording.wav'","code":1}
_   _       _    _   _  alert("error play2:" + JSON.stringify(error));
               _    });

_    _  __  _   mediaRec.play();
_       _       });
        });

  _ }

A:

I solved this problem by passing_cdvfile: path to_the Media_plugin in PlayAudio function code and copying the file_from Temp storage to persistent storage.
I had to use localURL of_the file.
This part solved my problem:
fileEntry.file(function (file) {
      __     _     _   _   __playNow(file.localURL);
_  _ _   _   _       _  }

For_full functions refer code sn