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

244
Views
Reproductor de audio personalizado en reaccionar JS - Control de volumen

Estoy construyendo un reproductor de audio personalizado en React JS, actualmente estoy atascado con los controles de volumen en el reproductor de audio

Aquí está mi código

La barra de progreso funciona bien. ¿Cuál debería ser la lógica detrás del control de volumen?

 const [currentTime, setCurrentTime] = useState(0); const progressBar = useRef(); const audioPlayer = useRef();

AduioPlayer.js

 .... <audio ref={audioPlayer} src="something.mp3" preload="auto" volume ></audio> // Volume Control Range slider <input type="range" defaultValue="0" className="mx-2 progressBarvolume bar volume" /> // Progress Bar <input type="range" className="progressBar bar" defaultValue="0" ref={progressBar} onChange={changeRange} /> ....

Función de cambio de rango:

 const changeRange = () => { audioPlayer.current.currentTime = progressBar.current.value; changePlayerCurrentTime(); };

función changePlayerCurrentTime:

 const changePlayerCurrentTime = () => { progressBar.current.style.setProperty( "--seek-before-width", `${(progressBar.current.value / duration) * 100}%` ); setCurrentTime(progressBar.current.value); };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Los elementos HTML de audio tienen una propiedad de volumen a la que puede acceder. Deberá tener un evento onChange en su control deslizante de audio.

Algo como esto dentro de su método onChange funcionará:

audioPlayer.current.volume = e.target.value / 100;

donde e es el ChangeEvent pasado al método onChange.

about 4 years ago · Juan Pablo Isaza Report
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!