A looped howl from howler js will not respond to pause commands

24 Views Asked by At

I'm encountering an issue where a single play command using Howler.js wont pause/stop in my React/Next.js application. I've tried to debug the issue, but I can't seem to figure out why this is happening.

Here's a code snippet showing the same:

import {howl,howler} from 'howler'export default function Home() {
let h = new Howl({src:"B.m4a", loop:true})
h.play()
return(
    <div>
        <button onClick={()=>{
            h.seek(0)}} >do</button>
    </div>
)

Despite my attempts to stop a looping howl in my code, I noticed an unexpected behavior. Specifically, when I executed h.seek(0), I realized that the track was playing twice. Upon seeking to the beginning, one track persisted while another restarted. This suggests that the sound is playing twice. Strangely this made sense because when I used h.stop(), the howl's volume and fidelity seem to be affected—appearing lower yet improved.

I'm struggling to identify the root cause of this issue. Any assistance on this would be greatly appreciated.

0

There are 0 best solutions below