Hi @hans.melberg
here’s an approach.
https://anvil.works/build#clone:VPMKXDIAKDPEGRGY=ONMRE3XORAHRQQNCUOHYIVQQ
Audio recorder custom form has been configured as custom component, so it can raise events and has a property “audio”.
Then in the javascript I set the hooks for getting the audio binary when “stop” is clicked.
Actually anvil can pass to python code also the Javascript’s native blob object, the problem is anvil doesn’t know how to manage it (or at least I don’t know how to do that in Anvil).
So the trick is - as you pointed - base64 encode the audio binary and send the string to Anvil code, then convert back to binary in a media object.
Curiously, the base64 conversion code doesn’t work in client code so I had to code a server function for that.
In the end: not a coding masterpiece but a starting point illustrating a working way.
Hope this helps.
BR
5 Likes