Sorry, as the code is really simple and the error is just a simple permission thing I though it wouldn't help.
I've tried locally on my computer, on our server and remote server, setting all permissions to read/write on the applet folder, etc...
ERROR MESSAGE:
Tue Jan 19 13:36:48 GMT 2010 JEP creating applet triggerMP3_9 (http://www.avert.org/applet/)
Exception in thread "Animation Thread" java.security.AccessControlException: access denied (java.io.FilePermission cheering.mp3 read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323
)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
at java.io.File.length(File.java:846)
at org.tritonus.share.sampled.file.TAudioFileReader.getAudioFileFormat(TAudioFileRe
ader.java:107)
at javazoom.spi.mpeg.sampled.file.MpegAudioFileReader.getAudioFileFormat(Unknown Source)
at javax.sound.sampled.AudioSystem.getAudioFileFormat(AudioSystem.java:1051)
at beads.AudioFile.<init>(Unknown Source)
at beads.AudioFile.<init>(Unknown Source)
at triggerMP3_9.setup(triggerMP3_9.java:35)
at processing.core.PApplet.handleDraw(PApplet.java:1402)
at processing.core.PApplet.run(PApplet.java:1327)
at java.lang.Thread.run(Thread.java:637)
Quote:import beads.*;
AudioContext ac;
SamplePlayer player1, player2;
float myLength;
void setup(){
size(300, 300);
String path = "cheering.mp3";
ac = new AudioContext();
try{
Sample sound = new Sample(new AudioFile(path));
myLength = sound.getLength();
println(myLength);
player1 = new SamplePlayer(ac, sound);
player1.setLoopType(SamplePlayer.LoopType.NO_LOOP_FORWARDS );
Gain g = new Gain(ac, 2, 1);
g.addInput(player1);
ac.out.addInput(g);
ac.start();
}
catch(IOException e){
println(e);
}
catch(javax.sound.sampled.UnsupportedAudioFileException e){
println(e);
}
}
void draw(){
scrub(player1);
}
void mousePressed(){
}
void scrub(SamplePlayer sp){
//sp.reTrigger();
float p = map(mouseX, 0 ,width, 0, myLength);
if(sp!=null) sp.setPosition(p);
}
My first test wasn't using audioFile but sampleManager (player = new SamplePlayer(ac, SampleManager.sample(path));) and I was getting the same error message. I've tried every possibilities, in the data folder, full path, in a folder next to the applet , straight next to the applet, url. I also tried to set sampleManager to stream.
If I use a URL (http://www.avert.org/applet/cheering.mp3) I get this error message even when running it in processing:
Code:
AudioFile cannot determine the duration of the file. Is it missing the duration tag?
javax.sound.sampled.UnsupportedAudioFileException: AudioFile cannot determine the duration of the file.
Thanks
ps: tested in Firefox 3.5.7, safari 4, osx 10.6, osx 10.5.8, java plugin 1.6.0_17