我有一个旧的血氧饱和度测定仪(那种附着在您的拇指上)。我想看看是否可以将其插入PC上的麦克风插孔,然后使用getUserMedia API将数据流式传输到iFrame。
这是我到目前为止拥有的JS:
window.AudioContext = window.AudioContext ||
window.webkitAudioContext;
const context = new AudioContext();
navigator.mediaDevices.getUserMedia({audio: true}).
then((stream) => {
const microphone = context.createMediaStreamSource(stream);
const filter = context.createBiquadFilter();
microphone.connect(filter);
var frame = createEle("iframe");//createEle is just create element function from my library
frame.sandbox = "allow-scripts";
updateFrame();
function updateFrame(){
setTimeout(function(){
frame.srcdoc = filter.context.listener.value;//i want frame to display oximeter value and refresh every second
console.log(filter.context.listener);
updateFrame();
},1000);
}
heartPage.append(frame);//heartPage is just a static element on my page
});