Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
How to define document in javascript blob?

I want to create an audio object in the blob but i couldn't.

const blobCode = () => {
    return `
    var sound      = document.createElement('audio');
    sound.id       = 'audio-player';
    sound.controls = 'controls';
    sound.src      = 'media/Blue Browne.mp3';
    sound.type     = 'audio/mpeg';
    document.body.appendChild(sound);
    class WhiteNoiseProcessor extends AudioWorkletProcessor {
    process (inputs, outputs, parameters) {
      const output = outputs[0]
      output.forEach(channel => {
        for (let i = 0; i < channel.length; i++) {
          channel[i] = Math.random() * 2 - 1
        }
      })
      return true
    }
  }
  
  registerProcessor('white-noise-processor', WhiteNoiseProcessor);`
}


const audioContext = new OfflineAudioContext(1, 128, 300000);


var blob_url = new Blob([blobCode()], {
    type: "text/javascript"
});
var blob_url_create = URL.createObjectURL(blob_url);
await audioContext.audioWorklet.addModule(blob_url_create).then(async () => {
    var wa = new AudioWorkletNode(audioContext, "white-noise-processor");
});

If i set the Blob type text/javascript get the error Uncaught ReferenceError: document is not defined

var blob_url = new Blob([blobCode()], {type: "text/javascript"});

If i set the Blob type text/html get the error Uncaught DOMException: The user aborted a request

var blob_url = new Blob([blobCode()], {type: "text/html"});

How do i resolve this error?

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!