使用javascript通过麦克风插孔从拇指血氧仪获取数据

时间:2019-06-08 23:57:52

标签: javascript iframe getusermedia

我有一个旧的血氧饱和度测定仪(那种附着在您的拇指上)。我想看看是否可以将其插入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
});

0 个答案:

没有答案