2
$\begingroup$

I have around 10 music files in a directory and I load them as AudioStream as shown:

dir = SetDirectory@NotebookDirectory[];
files = FileNames["*.mp3",dir];
stream = AudioStream[Audio[#]]& /@ files;

The variable stream is now a list of 10 AudioStream. Now when I play it using AudioPlay

AudioPlay[stream]

All the AudioStream start playing simultaneously.

How do I make them play one by one, automatically when one gets over the next one should start, as well as manually, like having a button which when clicked would play the next audio on the list?

$\endgroup$
1
$\begingroup$

You were very close, but you are creating multiple AudioStream's. Instead you can create a single AudioStream which can play multiple files one after another:

dir = SetDirectory@NotebookDirectory[];
files = FileNames["*.mp3",dir];
stream = AudioStream[Audio /@ files];

AudioPlay[stream]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.