serversideup / amplitudejs

AmplitudeJS: Open Source HTML5 Web Audio Library. Design your web audio player, the way you want. No dependencies required.
https://521dimensions.com/open-source/amplitudejs
MIT License
4.18k stars 425 forks source link

AmplitudeJS callbacks #276

Closed ValiantCuriosity closed 6 years ago

ValiantCuriosity commented 6 years ago

Question Checklist

Question Subject

I must be using the callback feature incorrectly. I can't get any callbacks to work properly as mentioned in the documentation.

Question Description

I am trying to create a pause with a set duration of time between song/audio file. So, song 1 plays. Then, there is a pause for 5 seconds. Then song 2 plays

At this point, the user generally doesn't use the play/pause button except to start the audio. Then Amplitude audio just plays through the list.

I used the Blue demo example to be certain that I was using proper Amplitudejs code. The only change I made was to replace the song files with first my .m4a and, then, my mp3 files. (I used .m4a first, but then changed to .mp3 since the original demo example used that audio format. )

I have also tried every other callback that is listed in the docs. Regardless of the callback used, the audio sample always continues to play one song/audio file after another in the list. There is no pause before going to the next audio sequence: song_change.

Again, I'm trying to figure out how to create a defined pause between the audios as they play in a list. Eventually, I'd like the user to be able to choose the amount of duration time, but for now, I'm simply trying to program a duration into the list.

I hope that what I'm trying to accomplish is clear. TIA

Here is the script code. I changed nothing except the json file url information:

``

ValiantCuriosity commented 6 years ago

Anyone? Please. :-)

danpastori commented 6 years ago

Hi @ValiantCuriosity! Sorry for the late reply. I made the process really simple!

First, download the dev branch of AmplitudeJS: https://github.com/521dimensions/amplitudejs/tree/dev

Then when you initialize AmplitudeJS add the following to your config:

Amplitude.init({
"songs": [..your songs array..],
"delay": 5000
});

Your delay can be any number of milliseconds. In this case 5000MS = 5 seconds. When the song ends, it will wait the delay amount before the next song begins. Let me know how this works!

ValiantCuriosity commented 6 years ago

Wow! Thanks, it works beautifully. I've been updating a different app and haven't gotten a chance to try out the delay feature.

It seems to work perfectly. Now, if I can just get something programmed with it that will allow a user to input the delay time that they need. In my app, each person needs a different amount of time at the end of the audio. Thanks Dan. Amplitude is a wonderful piece of programming. -Rachel

danpastori commented 6 years ago

@ValiantCuriosity Glad it worked! So what I'll do is add a public method to allow for a time to be set through Javascript. This way you can take the user's input and make it work! Thanks for the kind words on Amplitude as well and let us know if you need any other features added!

ValiantCuriosity commented 6 years ago

OH THANK YOU! The additional ability to let a user program their own delay would be FANTASTIC.

This is kind of you to do the work and allow us to use it.

With Gratitude, -Rachel

On Aug 17, 2018, at 1:12 PM, Dan Pastori notifications@github.com wrote:

@ValiantCuriosity https://github.com/ValiantCuriosity Glad it worked! So what I'll do is add a public method to allow for a time to be set through Javascript. This way you can take the user's input and make it work! Thanks for the kind words on Amplitude as well and let us know if you need any other features added!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/521dimensions/amplitudejs/issues/276#issuecomment-413976087, or mute the thread https://github.com/notifications/unsubscribe-auth/AkhlbusUNzF9WEE4yIQLkhok5Y4Hr_t7ks5uRyOdgaJpZM4VZUua.

danpastori commented 6 years ago

If you grab the newest dev branch, there's a public Amplitude.setDelay( time ) method which is the delay in milliseconds before going to the next song. https://github.com/521dimensions/amplitudejs/tree/dev