随时随地阅读更多技术实战干货,获取项目源码、学习资料,请关注源代码社区公众号(ydmsq666)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Database Example</title>
<script type="text/javascript" charset="UTF-8" src="cordova.js"></script>
<script type="text/javascript" charset="UTF-8">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
}
function onSuccess(media_files){
var i,len;
for(i=0,len=media_files.length;i<len;i+=1){
processFiles(media_files[i]);
}
alert('success'+media_files.length);
}
function processFiles(media_file){
//自定义处理
}
function onError(){
alert('error');
}
//捕获音频
function captureAudio(){
navigator.device.capture.captureAudio(onSuccess,onError,{limit:2});//4个剪辑
}
</script>
</head>
<body>
<button onclick="captureAudio();">captureAudio</button>
</body>
</html>