我使用Cordova媒体插件构建了一个Android应用程序来录制音频。
当我按下录制按钮时,它会创建一个音频文件。
重新编码完成后:
使用后退按钮时如何解决此问题?
.controller('myController', function($scope, $ionicPlatform, $cordovaMedia,$cordovaDevice , $timeout, $interval) {
$scope.timerWithInterval = 0;
//$ionicPlatform.ready(function() {
try {
$scope.timerWithInterval = 0;
var mediaRec;
$scope.startRecord = function() {
$scope.timerWithInterval = 0;
if($scope.myInterval){
$interval.cancel($scope.myInterval);
}
$scope.onInterval = function(){
$scope.timerWithInterval++;
}
$scope.circle = "outer-circle-active";
$scope.myInterval = $interval($scope.onInterval,1000);
var random = Math.floor((Math.random() * 100000) + 1);
var src = "myrecording_"+random+".mp3";
$scope.mmediaRec = new Media(src,
// success callback
function(e) {
console.log("recordAudio():Audio Success");
},
// error callback
function(err) {
console.log("recordAudio():Audio Error: "+ err.code);
});
// Record audio
$scope.mmediaRec.startRecord();
};
$scope.stopRecord = function() {
$scope.timerWithInterval = 0;
$interval.cancel($scope.myInterval);
$scope.staus = "successfully saved";
$scope.mmediaRec.stopRecord();
mediaRec.release();
};
} catch (e) {
console.warn("onDeviceReady error: " + e)
alert("onDeviceReady error: " + e);
}
//});
})