Sound Editor in Snap (Part 1)

Awesome! Could you try to develop a system that detects if your in the editor?

Yes! I think I can figure out some JS.
(Hopefully it comes out decent)

Alrighty, I get to work on uploading and downloading.

One more question, should we post it on both of our profiles? I want to add some more projects to my profile.

yes we can but we need to give credit to the other person for helping each other.

Here's a library to read and import files, and this is the block you should be using to actually import the files.
Also here's a block to download sounds.

Oh, ok then. I'll do that!

I tried to make some JS, but sadly the way I used does not work at all because only a few JS function work in the community site and the

return 1 ;

was one of them.

@helicoptur and @bh , we would like some help.

I think this might work.

return location.href === parent.location.href;

Put it inside a NOT block to see if it's running in the project page.
Basically, it checks if the window is running in an iframe or not.

That's because the project page is running an iframe, which means the window in the project is not the same as the window in the community site. This leads to many scripts failing such as downloads. However, there is a solution to this. Anything that comes after window. or is referenced despite not declaring it earlier on, should be prefixed with top.window. (It's fine if it says window.window, it will still work but is a bit ugly.)

@joecooldoo , the deeds have been done.

Thanks, @helicoptur!

Ok, so the "Save Sound" Custom Block is still not working on the community site. i have uploading working perfectly though.
https://snap.berkeley.edu/project?user=joecooldoo&project=Snap!%20Audio%20Player

So, it's letting you upload files but not download them?
Aha, I've found the problem.
Your code:

top.window
var a = document.createElement("a");
a.href = sound.audio.src;
a.download = sound.name;
a.click();

You're not supposed to prefix the entire code with that. You need to do this:

var a = top.window.document.createElement("a"); /* Top.window is put
                                                   before the reference
                                                   of the Document object,
                                                   which would otherwise
                                                   rely on the window in the
                                                   iframe. */
a.href = sound.audio.src;
a.download = sound.name;
a.click();

how 2 upload?

I recommend looking here instead though of the iFrame though.

Click the green arrow to upload.

It does not work.

go to the link i last sent.

I imported a song manually:
Snap! Audio Player script pic-2
and saw that the little spikes and stuff do not actually mean anything, what are they even supposed to be @bh !

Go here:
https://snap.berkeley.edu/project?user=joecooldoo&project=Snap!%20Audio%20Player