方式一:
利用js的Api AudioContext来播放:
var AudioContext = window.AudioContext ||
window.webkitAudioContext ||
window.mozAudioContext ||
window.oAudioContext ||
window.msAudioContext;
function playAuido(blob){
var fr = new FileReader();
fr.onload = function () {
var arrBuff = this.result; // ab是转换后的结果
audioContext.decodeAudioData(arrBuff, function (buffer) {
var source = audioContext.createBufferSource();
source.buffer = buffer; // This is the line that generates the error
source.connect(audioContext.destination);
source.start(0);
}
}
fr.readAsArrayBuffer(blob);
}
方式二:
利用auido标签播放:此种方式兼容IE9以上。原理是直接将aduio的src地址指向保存二进制流的