Lucas Kim
Lucas Kim

Reputation: 11

Migrating ScriptProcessorNode into AudioWorkletNode

I am capturing audio in background now. But the version was updated from Manifest v2 into Manifest v3. I changed the way to capture audio in Manifest v3 because the audio capture in background.js was prevented in Manifest v3. I used the old code but this warning doesn't disappear in console. enter image description here This is a class which is used to capture audio in Manifest v2 but I used this in Manifest v3 of chrome extension.

class Recorder {

    constructor(source, configs) {
        this.context = source.context;
        if (this.context.createScriptProcessor == null)
            this.context.createScriptProcessor = this.context.createJavaScriptNode;
        this.input = this.context.createGain();
        source.connect(this.input);
        this.buffer = [];
    }

    startRecording() {
        if (!this.isRecording()) {
            let numChannels = this.numChannels;
            let buffer = this.buffer;
            let worker = this.worker;
            this.processor = this.context.createScriptProcessor(
                this.options.bufferSize,
                this.numChannels, this.numChannels);
            this.input.connect(this.processor);
            this.processor.connect(this.context.destination);
            this.processor.onaudioprocess = function (event) {
                if (strRecordStatus === 'RECORDING') {
                                    ....
                }
            };
        }
    }
}

I try to remove this warning by migration from deprecated ScriptProcessorNode into AudioWorkletNode. But I am not sure how to migrate this API in Manifest v3. Looking forward to find out the way how to do it.

Upvotes: 0

Views: 50

Answers (0)

Related Questions