Howler.js: Play / Pause function for Howler.js

Created on 21 May 2019  路  4Comments  路  Source: goldfire/howler.js

Hello:

How can I re-create this function on Howler to PLAY / STOP a single audio file using the same button or image as trigger.

function togglePlay() {
return myAudio.paused ? myAudio.play() : myAudio.pause();
};

Most helpful comment

Hello!
According to the Howler documentation:

playing(id)
Check if a sound is currently playing or not, returns a Boolean (...)

So the method you were looking for is myAudio.playing().

Here is that code example you sent, adapted to this method.

function togglePlay(){
return myAudio.playing() ? myAudio.pause() : myAudio.play();
};

All 4 comments

Hello!
According to the Howler documentation:

playing(id)
Check if a sound is currently playing or not, returns a Boolean (...)

So the method you were looking for is myAudio.playing().

Here is that code example you sent, adapted to this method.

function togglePlay(){
return myAudio.playing() ? myAudio.pause() : myAudio.play();
};

Will be great if working code is provided for better clarity of playing

actually, that's the code right there... All you need is to copy the rest of the sample code from the docs @goldfire provides!!! Happy coding!

Thanks for the reply !

Actually I set the timer to get the position of the song after every 3 sec. Post the song is paused player.pos() is giving me the normal song speed position it didn't giving me the paused song position.
so i have a doubt that song is actually getting paused or not.

Any solution for this ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joshbruce picture joshbruce  路  4Comments

sibelius picture sibelius  路  3Comments

bflora2 picture bflora2  路  4Comments

tvbird picture tvbird  路  4Comments

proyb6 picture proyb6  路  4Comments