Web API - Download audio

I need to make a request to my server, that will return an audio. I then need the app to play it. The “play it” part is easy once a have an audio file, question is how I get it.

Any supported way to get an audio from the server and then play it will work for me.

If you don’t have a way to access an API on your server, can you store the file somewhere that has one like Cloudinary or maybe Dropbox?

If it helps it to then download it to the device via the app an play it, I could look up a way.

To confirm, I can access API. The issue is that don’t know how I can access the file once it sends it back in a response.

1 Like

What format is the response that contains the audio file? Can you post an example?

1 Like

I’m just about to write the server code for it. What format do I need to receive it via the Web API component and play the audio?

1 Like

Ideally, you would just use the hosted url with the Play Sound block and not need an API at all. But I guess you could try sending it an mp3 file from your API. What’s the point of that?

The documentation doesn’t mention that ability but it might work: Sound - Thunkable Docs

1 Like

I’ve found your thread about a similar problem:

How did you create the “Sound1” element? What is it?

I can only see default elements in the block view, how do I create a sound element and add it to this dropdown?

I highlighted in yellow the Any Component block you’ll need in that same topic you linked to. See the second post there.

Hi again,

Thanks for helping me out here.

I’ve tried your blocks from this tread

It’s in the non-DnD mode. It didn’t work for playing a base64 sound.

I also tried this in the DnD mode, didn’t work either. There was no error, but there wasn’t any sound either.

Do you think there’s any mistake on these screenshots? Feels like you may be my only chance in figuring out a way to play base 64 :pensive:

The main difference was that mine was a .wav file and yours is an .mpeg.

Can you try a .wav file?

Can you share a link to your project?

Sure, here is the project link:
https://x.thunkable.com/copy/1916c22eed20bbc11ad94242ab0a161b

Tried wav, the error code was different:

  • mpeg: Failed to load sound source
  • wav: Failed to load because no supported source was found

UPD: it’s working on iPhone, those errors were from the web emulator

I see the same error when I play a .wav file in a browser. And it works for me on iPhone. I’m not sure why that would be the case.

1 Like

Ditto - I found this when I was trying to run in the web tester too. This only seems to work on device in my experience for some odd reason.