Requested example of Autoplay Audio tracks in sequence


(Mark Hunte) #1

@felipxbr wanted to know how to have some tracks play in sequence from a track list.

This is a quick and dirty example of one way to have Audio tracks play each track in sequence.

This example uses a simple array as the track list.
We use two global vars to work out which track to play.
1, is the length of the track array.
2, is the track number.

We simply compare the current track play number with the count of tracks. Then increase the number if it is not greater than the tracks count.

This give us the next track number to play. ( Array number start at 0, so track one is 0 track two is 1 so we alway deduct 1 from the length of the track array)

We have the first track to play, hard coded as 0.
So when we hit the start button the track 0 will play.
We have a addEventListener that listens to when playing has ended. This will trigger the track number to play to increase by 1 and call the function that will play the next track.

All very simple…

playaudio.hype.zip (500.0 KB)

Please feel free to post your own versions or better ways, I am sure there are…


(Andre Felipe) #3

Thank you for it!
In this example how put a simple progress bar ?

thanks again!


(Mark Hunte) #4

Hi,

What do you mean by simple.


(Andre Felipe) #5

I tried merge this project below ( progress bar with draggable only )
with your example but I can not:

http://tumult.com/support/examples/4156-audio-counter/audio_bk.hype.zip

my goal is something like this:

Please, you can show a way?

Thanks!


(Mark Hunte) #6

Working with some one else code can always be a challenge.

I have added my code to the other. ( was not simple due to above statement ) but I think I have it as simplified as I can get it with both sets of code mashed together and without re writing and laying out a new Hype project.

audio_bk_v2.hype.zip (1.1 MB)


(Andre Felipe) #7

Thank you very much!


(Andre Felipe) #8

Works flawlessly!

But…

Please, how do put this playlist in html page with links for random choosing?

Thanks!


(Mark Hunte) #9

Can you explain that a bit better of what you mean.


(Andre Felipe) #10

Sorry my bad English . I just need to place the links to choose which song to start playing .


(Andre Felipe) #11

Please, any idea?


(Mark Hunte) #12

Not really,

You did not elaborate on what you wanted. You already have the tracks auto play and in sequence.
So how are you expecting the a playlist to work.

Also what do you have that you have tried so far…