Integrate Processing with Minim Libraries in Website

岁酱吖の 提交于 2019-12-08 02:45:52

问题


I have seen similar questions posted before but seems the general answer is that it cannot be done.

So, here is my HTML code :

<head>
  …
  <script type="text/javascript" src="js/processing.js"></script>
  …
</head>

<body>
  …
  <canvas id="my_prog" data-processing-sources="project/my_prog.pde project/my_class.pde"/></canvas>
  …
</body>

And in my sketch I use Minim libraries :

import ddf.minim.*; import ddf.minim.spi.*; import ddf.minim.ugens.*;

Instead of having my project on my website, there is a rectangular shape proportional to the project size, but without image and sound.

Moreover, this method doesn't work either… I do not know what to do.

Any suggestions? :)

Thank you,

Thib


回答1:


Think about it this way:

  • "Core Processing" contains all of the variables and functions you can use in a plain old Processing sketch.
  • You can deploy "core Processing" as a Java application. If you do so, you can also use Java libraries, like minim.
  • You can also deploy "core Processing" as JavaScript using Processing.js. If you do so, you can embed your sketch into a webpage and use JavaScript syntax to access the html components of that surrounding webpage.
  • But you can't mix them: you can't embed a Java application in a webpage (applets are dead), and you can't use Java libraries in a JavaScript webpage.

Minim is a Java library, so you can't use it directly in a JavaScript application. Instead, you have to find a JavaScript library that does something similar. You've posted one method (what do you mean when you say it didn't work?), but googling "processing.js audio" or "minim javascript" returns a bunch of others, including this related question:

Exporting a Processing sketch with audio to JavaScript

Also, you should get acquainted with the JavaScript console. In your web browser, press F12, then go to the console tab, then refresh your page. That will show you any errors you're hitting, that way you have more information than "it's a blank rectangle".



来源:https://stackoverflow.com/questions/31800512/integrate-processing-with-minim-libraries-in-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!