Okazari / Rythm.js

A javascript library that makes your page dance.
https://okazari.github.io/Rythm.js/
GNU General Public License v3.0
3.93k stars 250 forks source link

any way to catch the audio is finished play? #88

Closed jackbbhua closed 6 years ago

jackbbhua commented 6 years ago

any way to catch the audio is finished play? so we can move out rythm class,add new rythm class or change another css when new audio been loaded to rythem JS. thank you very much.

Okazari commented 6 years ago

Hey Jackbbhua.

If you manage to get the audio element, you have the ended event. https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Media_events

Currently, if you want to get the audio element along with rythm.js you need to create and manage the audio element by yourself and use

/* Used to collaborate with other players library
 * You can connect Rythm to an audioElement, and then control the audio with your other player
 */
rythm.connectExternalAudioElement(audioElement)

I could also expose the audio element as rythm.audio (or you could do this as a PR ? ;) )

WDYT ?

jackbbhua commented 6 years ago

i will try it,let you know it will works or not.thank you Okazari.

jackbbhua commented 6 years ago

Hi, Okazari I use ended event to catch the audio is end.it works.thank you in advance.

Okazari commented 6 years ago

Glad it worked :) !