mercredi 29 juillet 2020

Restart JS variable data when generating random audio file

I have this really bugging problem with my JS and it relates to audio.
I am retrieving data from an API source with multiple audio files within... an example of one of those files would look like this... cool_audio_file/1, cool_audio_file/2, cool_audio_file/3, etc. So I made it generate a random number and insert at the end of the file name. 'cool_audio_file/'+randomnum I also have an option to generate a random "album" which based on randomnum generates the corresponding title.

<h1>Album</h1>
<button>Click to play</button><br>
<button>Generate Another!</button>

When a user clicks generate another, it generates another random number and assigns it to randomnum and plays it's audio, both audio play at the same time, In other words, all history of randomnum is played. So I guess my question is, how do you restart the variable info when you click again...




Aucun commentaire:

Enregistrer un commentaire