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

257
Views
Estoy usando Web Audio API con React, pero DecodeAudioData no usa un ArrayBuffer para reproducir un archivo

Este código funciona bien en Vanilla JS, pero cuando está en un componente de React audioContext.decodeAudioData (buffer) devuelve el error:

"DOMException no detectada (en promesa) DOMException: The buffer passed to decodeAudioData contains an unknown content type. (Necesita un arrayBuffer)

Cuando registro el búfer que paso al decodificador, de hecho es un ArrayBuffer . He intentado crear ArrayBuffer de diferentes maneras, como usar diferentes tipos de archivos, pero nada ha funcionado.

Construí esta siguiente documentación y algunos ejemplos, hasta ahora creo que podría ser un problema con React.

Si alguien tiene una solución alternativa o alternativa, sería increíble. Gracias por tomarte el tiempo.

 import { audioContext, primaryGainControl } from "../App"; const Channel = () => { /*console.log(audioContext); console.log(primaryGainControl);*/ const [volume, setVolume] = useState(80); const channelGain = audioContext.createGain(); channelGain.gain.setValueAtTime(0.8, 0); channelGain.connect(primaryGainControl); //Global variables var startTime = 0; var offsetToResume = 0; var pauseTime = 0; var isPlaying = false; var songSource = audioContext.createBufferSource(); var rate = 1; var isPlaying = false; var FILE_URL = "271417__soneproject__hats-6.wav"; const playAudio = async () => { if (isPlaying) return; channelGain.gain.setValueAtTime(volume / 100, audioContext.currentTime); const response = await fetch(FILE_URL); const buffer = await response.arrayBuffer(); const songBuffer = await audioContext.decodeAudioData(buffer); //Here is where the error occurs ^ ^ songSource = audioContext.createBufferSource(); songSource.buffer = songBuffer; songSource.connect(channelGain); startTime = audioContext.currentTime; songSource.start(audioContext.currentTime, offsetToResume); isPlaying = true; }; ...
about 4 years ago · Juan Pablo Isaza
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!