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

180
Views
how to pause the other while one is playing wavesurfer.js?

We decided to use wavesurferJS in our React project. I have multiple audio files. How do I make the others stop when I play one of them? We tried almost all the solutions over the web. Nothing helped. Any help is appreciated.

import React, { useRef, useEffect, useState } from "react";
import WaveSurfer from "wavesurfer.js";

const VoiceItem= ({url }) => {
  const waveformRef = useRef();
  const [wavesurfer, setWavesurfer] = useState(null);

  useEffect(() => {
    if (waveformRef.current) {
      const wave = WaveSurfer.create({
        container: waveformRef.current,
      });
      wave.load(url);
      setWavesurfer(wave);
    }
  }, []);

  const togglePlayPause = () => {
    wavesurfer.playPause();
  };

  return (
    <div>
        <button onClick={togglePlayPause}>
        </button>
        <div ref={waveformRef}></div>
    </div>
  );
};

export default VoiceItem;
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!