best strategy to stream play an MP3 from url while saving it to SD card #507
-
So, assuing a remote MP3 file such as : https://file-examples.com/storage/fe352586866388d59a8918d/2017/11/file_example_MP3_1MG.mp3 what would be the best strategy to save it to the SD card, while playing it. I havent found such option in audio-tools but i may have missed it since the library is quite extensive. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Just copy the data from an URLStream to a MultiOutput which will go to a File and to an EncodedAudioStream. |
Beta Was this translation helpful? Give feedback.
-
while trying this i realized i dont have the file length, is there a way to get the file length (when this is a file and not an endless stream) from audiocopy or another function? for example i noticed i got [W] HttpRequest.h : 153 - no CONTENT_LENGTH found in reply |
Beta Was this translation helpful? Give feedback.
-
Sure it is in the HttpReplyHeader where you can just call get(CONTENT_LENGTH) on the attribute name CONTENT_LENGTH which returns a string. or use getReceivedContentLength() on the HttpRequest if you need a integer. |
Beta Was this translation helpful? Give feedback.
Just copy the data from an URLStream to a MultiOutput which will go to a File and to an EncodedAudioStream.