goldfire / howler.js

Javascript audio library for the modern web.
https://howlerjs.com
MIT License
24.05k stars 2.24k forks source link

I can't get the audio to pause #1555

Closed OdapX closed 2 years ago

OdapX commented 2 years ago

The Problem

I'm trying to build a sort of music player web app with nextjs , now the probleme is that once I get the audio to play It doesn't pause with the pause function .

here is my code :

code

the functions ara fired on click events, the playing the audio works just fine but it doesn't stop with the call of Pause function.

Reproducible Example

-

Reproduction Steps

-

Possible Solution

-

Context

I am trying to build a custom music player with react (Nextjs).

Howler.js Version

v2.2.3

Affected Browser(s)/Versiuon(s)

chrome

lustremedia commented 2 years ago

Did you try to pause it with an ID?
const id = sound.play() then sound.pause(id)

Maybe there might be an issue with sound being a const?

OdapX commented 2 years ago

I tried that but it doesn't work either , really don't know what causing this,

lustremedia commented 2 years ago

Your const Pause is capitalized, is that on purpose? However this is not a bug for sure but more like a debugging issue in your app. You should move that to discussions .... https://github.com/goldfire/howler.js/discussions and close this issue

suterma commented 2 years ago

Did you try to pause it with an ID? const id = sound.play() then sound.pause(id)

Late, but to clarify: As long as there is just one Howl, Id's are not necessary to use. I do this all the time, since I have only one sound at at time (also doing some kind of music player): https://github.com/suterma/replayer-pwa/blob/3b624091a035e8d4b94db6c81039a581b6d1a59d/src/components/TrackHowlerPlayer.vue#L350