Hi @hans.melberg
I’m surely no Javascript genius and I just proved it with my previuos post.
- you’re right the substring search must be done for
','
and not for', '
. - the problems you were facing were due to how I declared the event handler:
reader.onloadended = notifyAnvil(reader, audio_blob.type);
This whay the notifyAnvil function is called immediately and its result assigned to onloadended
.
This is not what we want.
We need to declare the handler this way:
reader.onload = function(e) {
console.log(e);
let base64String = reader.result;
console.log('Base64 String - ', base64String);
base64_audio_string = base64String.substr(base64String.indexOf(',') + 1);
anvil.call(calling_form, 'onStop', base64_audio_string, audio_blob.type);
};
This way the function is executed when the load ends successfully (yes, I also changed the event handler from .onloadended
to .onload
after having a look here).
Now it seems to work both in Firefox and Chrome and saves non-zero .objs in the database.
Of course, you can remove all those console.log and comments when everything’s working.
Bye
https://anvil.works/build#clone:36B5EBIQ3HMY3LSO=AP6LPH4VIB4P5GCSTIIA3BNN