function startRadio() {
mui.toast("开始录音 ");
r = plus.audio.getRecorder();
if (r == null) {
console.log("录音对象未获取");
return;
}
r.record({
filename: "_doc/audio/"
}, function(p) {
console.log("录音完成:" + p);
plus.io.resolveLocalFileSystemURL(p, function(entry) {
var fileReader = null;
entry.file(function(file) {
fileReader = new plus.io.FileReader();
console.log(fileReader);
radiopath = p;
fileReader.onloadend = function(evt) {
radiopath = p;
document.querySelector('#radio').style.display = 'none';
console.log("aaa::::" + evt.target.result);
sendSound(evt.target.result, p);
}
fileReader.readAsDataURL(file);
});
}, function(e) {
console.log("读取录音文件错误:" + e.message);
});
}, function(e) {
console.log("录音失败:" + e.message);
});
document.querySelector('#record').style.display = 'block';
t = 0;
ri = setInterval(function() {
t++;
rt.innerText = timeToStr(t);
}, 1000);
}
就是这一段,evt.target.result总是打印不出来,但是android上面可以,iOS上已打印就会报错误
java.io.EOFException
at java.io.DataInputStream.readUnsignedShort(Unknown Source)
at java.io.DataInputStream.readUTF(Unknown Source)
at java.io.DataInputStream.readUTF(Unknown Source)
at com.pandora.console.core.ConsoleLauncher.main(ConsoleLauncher.java:44)
3 个回复
DCloud_IOS_XTY
readAsDataURL经测试未发现问题,请提供可以复现问题的demo
heyuqin (作者)
function startRadio() {
mui.toast("开始录音 ");
r = plus.audio.getRecorder();
if (r == null) {
console.log("录音对象未获取");
return;
}
r.record({
filename: "_doc/audio/"
}, function(p) {
console.log("录音完成:" + p);
plus.io.resolveLocalFileSystemURL(p, function(entry) {
var fileReader = null;
entry.file(function(file) {
fileReader = new plus.io.FileReader();
console.log(fileReader);
radiopath = p;
fileReader.onloadend = function(evt) {
radiopath = p;
document.querySelector('#radio').style.display = 'none';
console.log("aaa::::" + evt.target.result);
sendSound(evt.target.result, p);
}
fileReader.readAsDataURL(file);
});
}, function(e) {
console.log("读取录音文件错误:" + e.message);
});
}, function(e) {
console.log("录音失败:" + e.message);
});
document.querySelector('#record').style.display = 'block';
t = 0;
ri = setInterval(function() {
t++;
rt.innerText = timeToStr(t);
}, 1000);
}
就是这一段,evt.target.result总是打印不出来,但是android上面可以,iOS上已打印就会报错误
java.io.EOFException
at java.io.DataInputStream.readUnsignedShort(Unknown Source)
at java.io.DataInputStream.readUTF(Unknown Source)
at java.io.DataInputStream.readUTF(Unknown Source)
at com.pandora.console.core.ConsoleLauncher.main(ConsoleLauncher.java:44)
DCloud_IOS_XTY
这个应该是HB在输出日志时出的问题,你使用alert打印下看看结果正常吗