[fpc-pascal] First pas2js public release

Michael Van Canneyt michael at freepascal.org
Sun Dec 24 10:36:05 CET 2017



On Sun, 24 Dec 2017, Ingemar Ragnemalm wrote:

>> 
>> In that sense, the demo demonstrates this. The server is just there for you
>> to be able to download the "program"...
>
> Exactly. I get a cross-platform solution with no installations, in a way that 
> users are increasingly used to. And I can write it in FPC, which I am a lot 
> more happy with than a rubbish language like JavaScript! For me it opens a 
> lot of possibilities!
>
> But let me get back to my current problems. I can accept loading images 
> through HTML for now, but how can I load and play sounds? There is an "Audio" 
> API in JavaScript but it seems that pas2js doesn't support it, it can't find 
> play(). I have searched web.pas and a few others for it. Where do I start to 
> fix that?

You go to e.g. MDN, look at the API, and write a series of import classes.

This looks like a good starting point:
https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_AP

If it was standard on all browsers (it is not on IE), then we could add it to
web.pas. But since IE does not support it,  the classes can then be added 
to a new units websound.pas.

The WIKI page of pas2js contains a rudimentary example that explains the
principle of an import class.

There is a demo (democlasstopas) that helps you to create a skeleton definition, 
I will add some documentation to the WIKI or maybe make it into a unit.

If you need help, mail me in private and I will do a few sample conversions.

Michael.



More information about the fpc-pascal mailing list