I have returned to ask another question that I can’t quite seem to find the answer to.
I am aware code.org uses java, therefore it has function calls that aren’t necessarily a block. Things like .isNaN, etc. Seeing as I can’t find anything, I was hoping maybe there was a way for me to adjust the volume of a playSound() with one of these undocumented functions?
Sound is played like this:
var mySound = "test.mp3";
playSound(mySound, false);
I have tried finding a call or function I can make to change the volume but have had no luck. I am not too sure if it’s even possible to do it.
It should be noted that I am currently using the AppLab, as I am pretty sure there is a volume system of some sort elsewhere.
I think playSound() and stopSound() are the only functions for controlling sound. There are a lot of hidden functions, but in App Lab most of them are only for manipulating the HTML code of the app. Alternatively, you could upload your sound file to a video editor and use it to change the volume of the actual file.
Also, just a quick side note, CDO uses JavaScript, not Java. The names are similar but the languages are completely different.
Hm, while this may work but it would involve uploading thousands of clips. You mentioned using those app functions to edit the HTML of the app; could this imply that there might be a function for the sound that I may be able to find somewhere?
Well, you can use a function called innerHTML() to edit the HTML code of any element. However, the HTML input is filtered first, and removes tags like the audio element. As far as I know, playSound() is the only way to generate audio in App Lab and Game Lab.
Yep, just put this handy piece of code in your app and it will log all design HTML:
startWebRequest("https://studio.code.org/v3/sources/"+getAttribute("divApplab", "baseURI").split("/")[5]+"/main.json", function(status,type,content) {
var HTML = JSON.parse(content).html;
console.log(HTML);
});
And you can use HTML to style elements in certain ways, like this:
innerHTML("label1", "<p>This is <i>example</i> text</p>");
It’s fun to play around with, but again, all inputs with innerHTML() are filtered to remove certain tags, so it’s very unlikely that you could get it to play audio.
Hm, what is this “filter”? Is it to prevent things like embeds? What exactly is this filtering? In addition, this code is amazing; I didn’t know you could process JSON files in code.org!
In addition, typing “innerHtml()” and clicking “examples” redirects to a removed page.
I presume you must know HTML to be able to grasp what is going on. Is this just pure HTML, or does it have some code.org flare to it?
I just tested the code provided, and as you mentioned above there was no mention of any sound objects. Unfortunately, this is not what I am looking for; Glad I tried, but I am going to have to make some redesigns to my project to work with this lack of functionality.
A.) modify the sound volume with a volume editor or some audio library before importing into CDO
B.) write your own custom API that handles sound metrics (which will mean much higher latency & a bunch of necessary knowledge of how to run a back end)
in my opinion if you just need a few samples at different volumes A would be your goto instead of building option B
but you know it wouldn’t be too hard to implement into CDO since basic html should allow that