We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › loading midis out of a online folder
Page Index Toggle Pages: 1
loading midis out of a online folder (Read 1226 times)
loading midis out of a online folder
Jul 6th, 2008, 5:23pm
 
Hi
I had written a sketch and now i want to get him online.

But in my sketch i use this to get a list of midis where i can choose.

Code:
 
String midiFolder = "...path/midis/";
File folder = new File(midiFolder);
String files[] = folder.list();
String actSong = files[int(random(files.length))];
score = JMEtude.createScore(midiFolder + actSong);


But how can i make this with a online folder?
Re: loading midis out of a online folder
Reply #1 - Jul 10th, 2008, 8:28am
 
I now tryed it another way.
The midi files are now in the data folder.

Code:

java.io.File folder = new java.io.File(dataPath("\\midis"));
String midiFolder = folder;
String files[] = folder.list();
String actSong = files[int(random(files.length))];
score = JMEtude.createScore(midiFolder + "\\" + actSong);


But the line
String midiFolder = folder;
give me an error, becous the file object isnt a String.
How can I create a String out of this File object?
Re: loading midis out of a online folder
Reply #2 - Jul 10th, 2008, 9:17am
 
java.io.File reference in the Java doc :
http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html

String getAbsolutePath()
Returns the absolute pathname string of this abstract pathname.
Re: loading midis out of a online folder
Reply #3 - Jul 10th, 2008, 9:54am
 
Thank you again antiplastik. Smiley
Re: loading midis out of a online folder
Reply #4 - Jul 10th, 2008, 11:59am
 
I dont understand why it not work.

Offline it works perfectly.
Get the midis from the data folder and plays it.

After exporting and uploading the sketch, nothing happens.

Here is the whole sketch with source code.

>>click
Re: loading midis out of a online folder
Reply #5 - Jul 10th, 2008, 12:08pm
 
see the Reference > Troubleshooting section about such browser/applet issues :
http://processing.org/reference/troubleshooting/index.html#applet

launch the applet in your browser and open the java console, and you will see that some exception are thrown indeed :

Quote:
Error while running applet.
java.security.AccessControlException: access denied (java.io.FilePermission null\data\midis read)
Page Index Toggle Pages: 1