PHP variables to Java applet?

621 views Asked by At

I have an audio visualizer applet I created with processing and minim using fft to analyze the audio. Now I want to feed in songs to the program dynamically with php as the user clicks on a song. I have read about JavaBridge and have it up and running with Tomcat. Would I need to store the song variable values in an xml file and send it over to the .java file? Is that the right approach? And if so, any idea what this would look like? I'm completely new to java and processing. Any help would be incredibly appreciated!

2

There are 2 answers

8
Andrew Thompson On BEST ANSWER

feed in songs to the program dynamically with php as the user clicks on a song.

Translations presumed for answer:

  • PHP to HTML.
  • 'clicks on a song' to 'clicks on a link'.

Since the HTML has links to songs, add an onclick() handler and in the called function, use JavaScript to call an applet method to load the required song.

So long as the applet is loading the song from the code base or document base, this should be allowable in a sand-boxed applet. Unfortunately doing so from a method called from JS complicates matters slightly, since the security sand-box is tightened even further.

If that is the case here, it will be necessary to wrap the call in a PrivilegedAction and call it using AccessController.doPrivileged(PrivilegedAction)

0
Joop Eggen On

The fundamental sequence is as follows:

  • The user request a .php page in the browser.
  • The web server lets PHP write the page. It can write HTML with an applet specified, the applet HTML can be written with parameter with values filled in by PHP.
  • The client receives an HTML page, which starts the applet.

So a click on the page cannot be handled by PHP, in a simple direct way. Follow @AndrewThompson in this.