Page 1 of 1

Play multiple audio in a row

Posted: Tue Jun 20, 2023 7:49 am
by Ajmal shariff
Hi All,

I am trying to modify the pipeline_a2dp_source_stream example code on my ESP32 LyraT board to play multiple audio files in a row. Currently the code is able to play one audio file and then it sends a PERIPH_BLUETOOTH_AUDIO_SUSPENDED event from bt_periphal and stops playing.

Once i receive the event I am handling it by stopping the audio and reloading a new file from SD card and resetting the ring buffer.
periph_bt_stop(bt_periph);
audio_pipeline_stop(pipeline);
audio_pipeline_wait_for_stop(pipeline);iph);
audio_element_set_uri(fatfs_stream_reader, "/sdcard/check.mp3");
audio_pipeline_reset_ringbuffer(pipeline);
audio_pipeline_reset_elements(pipeline);
audio_pipeline_change_state(pipeline, AEL_STATE_RUNNING );
periph_bt_play(bt_periph);
audio_pipeline_run(pipeline);

But it is not working as expected. Can anyone suggest me how to do it.

Thank you.

Re: Play multiple audio in a row

Posted: Sun Aug 13, 2023 10:49 pm
by felixcollins
There is quite a lot that has to happen correctly to reset and reuse an audio pipeline. The simplest approach to start with is just to deinit and destroy the entire pipeline and start a new one. Study all the ADF examples if you with to persist with your approach.

Re: Play multiple audio in a row

Posted: Mon Aug 14, 2023 6:15 am
by tempo.tian
It is quite easy, if all files are of same type: audio type is same, audio sample rate and bits are same.
You can check example:
https://github.com/espressif/esp-adf/bl ... _example.c, after file play to end, auto read next file.
If files are differnt type, it is complex, you can refer:
https://github.com/espressif/esp-adf/tr ... e_pipeline