|
按钮绑定touchstart与touchend事件,touchstart中写入的是参考的system/api/native/demo/test的开始录音,touchend里面是停止并上传录音。但是touchend中代码不会调用。代码如下:
Model.prototype.modelLoad = function(event){
var voices = window.voices = {
localId : '',
serverId : ''
};
voice.onVoiceRecordEnd({
complete : function(res) {
voices.localId = res.localId;
alert('录音时间已超过一分钟');
}
});
this.comp("audioBtn").set({disabled:true});
var self = this;
document.addEventListener("deviceready", onDeviceReady, false);
// 加载完成
function onDeviceReady() {
self.comp("audioBtn").set({disabled: false});
}
$("[xid=audioBtn]").on({touchstart:function(event){
voice.startRecord({
cancel : function() {
alert('用户拒绝授权录音');
},
});
},touchend:function(event){
voice.stopRecord({
success : function(res) {
voices.localId = res.localId;
voice.uploadVoice({
localId : voices.localId,
success : function(res) {
voices.serverId = res.serverId;
}
});
},
fail : function(res) {
alert(JSON.stringify(res));
}
});}
});
|
|