【问题标题】:The ScriptProcessorNode is deprecated. Use AudioWorkletNode insteadScriptProcessorNode 已弃用。改用 AudioWorkletNode
【发布时间】:2021-12-25 21:30:24
【问题描述】:

网站上有录音机和录音播放器。 Firefox 没问题,但我在基于 Chronium 的浏览器中收到以下警告。

[弃用] ScriptProcessorNode 已弃用。请改用 AudioWorkletNode。 (https://developers.google.com/web/updates/2017/12/audio-worklet)

this.config = {
                        bufferLen: 4096,
                        numChannels: 2,
                        mimeType: 'audio/ogg'
                    };
                    this.recording = false;
                    this.callbacks = {
                        getBuffer: [],
                        exportWAV: []
                    };
                    Object.assign(this.config, cfg);
                    this.context = source.context;
                    this.node = (this.context.createScriptProcessor || this.context.createJavaScriptNode).call(this.context, this.config.bufferLen, this.config.numChannels, this.config.numChannels);
                    this.node.onaudioprocess = function (e) {
                        if (!_this.recording) return;
                        var buffer = [];
                        for (var channel = 0; channel < _this.config.numChannels; channel++) {
                            buffer.push(e.inputBuffer.getChannelData(channel));
                        }
                        _this.worker.postMessage({
                            command: 'record',
                            buffer: buffer
                        });
                    };

Full Code on PasteBin

如何进行此更改?

【问题讨论】:

  • 我下面的回答没有回答你的问题吗?

标签: audio


【解决方案1】:

ScriptProcessorNode 已被“弃用”多年,但它不会很快消失。

但是,如果您想要在 Ogg 中录制 Vorbis 或 Opus 音频,则无论如何都不需要它。请改用 MediaRecorder API。 https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder

【讨论】:

    猜你喜欢
    • 2021-09-01
    • 2022-01-25
    • 1970-01-01
    • 2014-04-13
    • 2014-02-12
    • 2017-01-22
    • 2016-02-17
    • 2014-12-25
    相关资源
    最近更新 更多