function(win, lose, args) {
        var id = args[0];
        var thisM = Media.get(id);
        var srcUri = processUri(thisM.src);

        var dest = parseUriToPathAndFilename(srcUri);
        var destPath = dest.path;
        var destFileName = dest.fileName;
        var fsType = dest.fsType;

        var success = function () {
            Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STOPPED);
        };

        var error = function (reason) {
            Media.onStatus(id, Media.MEDIA_ERROR, reason);
        };

        thisM.mediaCaptureMgr.stopRecordAsync().done(function () {
            if (fsType === fsTypes.TEMPORARY) {
                if (!destPath) {
                    // if path is not defined, we leave recorded file in temporary folder (similar to iOS)
                    success();
                } else {
                    Windows.Storage.ApplicationData.current.temporaryFolder.getFolderAsync(destPath).done(function (destFolder) {
                        recordedFile.copyAsync(destFolder, destFileName, Windows.Storage.CreationCollisionOption.replaceExisting).done(success, error);
                    }, error);
                }
            } else {
                // Copying file to persistent storage
                if (!destPath) {
                    recordedFile.copyAsync(Windows.Storage.ApplicationData.current.localFolder, destFileName, Windows.Storage.CreationCollisionOption.replaceExisting).done(success, error);
                } else {
                    Windows.Storage.ApplicationData.current.localFolder.getFolderAsync(destPath).done(function (destFolder) {
                        recordedFile.copyAsync(destFolder, destFileName, Windows.Storage.CreationCollisionOption.replaceExisting).done(success, error);
                    }, error);
                }
            }
        }, error);
    }
function(win, lose, args) {
        var id = args[0];
        var thisM = Media.get(id);
        var srcUri = processUri(thisM.src);

        var dest = parseUriToPathAndFilename(srcUri);
        var destPath = dest.path;
        var destFileName = dest.fileName;
        var fsType = dest.fsType;

        var success = function () {
            Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STOPPED);
        };

        var error = function (reason) {
            Media.onStatus(id, Media.MEDIA_ERROR, reason);
        };

        thisM.mediaCaptureMgr.stopRecordAsync().done(function () {
            if (fsType === fsTypes.TEMPORARY) {
                if (!destPath) {
                    
                    success();
                } else {
                    Windows.Storage.ApplicationData.current.temporaryFolder.getFolderAsync(destPath).done(function (destFolder) {
                        recordedFile.copyAsync(destFolder, destFileName, Windows.Storage.CreationCollisionOption.replaceExisting).done(success, error);
                    }, error);
                }
            } else {
                
                if (!destPath) {
                    recordedFile.copyAsync(Windows.Storage.ApplicationData.current.localFolder, destFileName, Windows.Storage.CreationCollisionOption.replaceExisting).done(success, error);
                } else {
                    Windows.Storage.ApplicationData.current.localFolder.getFolderAsync(destPath).done(function (destFolder) {
                        recordedFile.copyAsync(destFolder, destFileName, Windows.Storage.CreationCollisionOption.replaceExisting).done(success, error);
                    }, error);
                }
            }
        }, error);
    }
function ( win , lose , args ) { var id = args [ 0 ] ; var thisM = Media . get ( id ) ; var srcUri = processUri ( thisM . src ) ; var dest = parseUriToPathAndFilename ( srcUri ) ; var destPath = dest . path ; var destFileName = dest . fileName ; var fsType = dest . fsType ; var success = function ( ) { Media . onStatus ( id , Media . MEDIA_STATE , Media . MEDIA_STOPPED ) ; } ; var error = function ( reason ) { Media . onStatus ( id , Media . MEDIA_ERROR , reason ) ; } ; thisM . mediaCaptureMgr . stopRecordAsync ( ) . done ( function ( ) { if ( fsType === fsTypes . TEMPORARY ) { if ( ! destPath ) { // if path is not defined, we leave recorded file in temporary folder (similar to iOS) success ( ) ; } else { Windows . Storage . ApplicationData . current . temporaryFolder . getFolderAsync ( destPath ) . done ( function ( destFolder ) { recordedFile . copyAsync ( destFolder , destFileName , Windows . Storage . CreationCollisionOption . replaceExisting ) . done ( success , error ) ; } , error ) ; } } else { // Copying file to persistent storage if ( ! destPath ) { recordedFile . copyAsync ( Windows . Storage . ApplicationData . current . localFolder , destFileName , Windows . Storage . CreationCollisionOption . replaceExisting ) . done ( success , error ) ; } else { Windows . Storage . ApplicationData . current . localFolder . getFolderAsync ( destPath ) . done ( function ( destFolder ) { recordedFile . copyAsync ( destFolder , destFileName , Windows . Storage . CreationCollisionOption . replaceExisting ) . done ( success , error ) ; } , error ) ; } } } , error ) ; }
Stop recording audio
Stop recording audio