Error setting file with APWidgets MediaPlayer
in
Android Processing
•
1 years ago
Hi Rikard, et al...
Trying to use APWidgets to play a different series of samples in Android. I've had success with it before, but in this case, I only have one player, and am attempting to change the media file with a string that reads from a directory on my SD Card.
I've been able to do this properly with the Android Media Player, but I want to use APWidgets, as I can test and set the current position easier with it's built in methods (have had trouble implementing the onCompletionListener class with pure Android) ...
I keep getting errors in the setMediaFile() method, though as far as I can tell, the String "playFileName" is getting the right data... though I have tried adjusting the slashes on Line #5 (see below) to single and double slashes, forwards and backwards (I've seen multiple comments/threads on which one is proper, but still a little unsure myself...)
Here is my function...
- void startPlaying() {
- println("Starting File...");
- if(current.getCurrentPosition() == 0) {
- try {
- playFileName = "//sdcard//SonicDrift//" + playFileName;
- println("PLAYING " + playFileName);
- current.setMediaFile(playFileName);
- current.setLooping(false);
- current.start();
- }
- catch(Exception e) {
- println("Couldn't load file" + e);
- e.printStackTrace();
- }
- }
- }
And the stack trace that is thrown to the console because of Line # 7
java.io.FileNotFoundException: //sdcard//SonicDrift//far.mp3
at android.content.res.AssetManager.openAssetFd(Native Method)
at android.content.res.AssetManager.openFd(AssetManager.java:330)
at apwidgets.APMediaPlayer.setMediaFile(APMediaPlayer.java:81)
at processing.android.test.sonicdrift.SonicDrift.startPlaying(SonicDrift.java:754)
at processing.android.test.sonicdrift.SonicDrift$PlayButton.playOn(SonicDrift.java:414)
at processing.android.test.sonicdrift.SonicDrift.State1(SonicDrift.java:605)
at processing.android.test.sonicdrift.SonicDrift.draw(SonicDrift.java:255)
at processing.core.PApplet.handleDraw(PApplet.java:1806)
at processing.core.PGraphicsAndroid2D.requestDraw(PGraphicsAndroid2D.java:161)
at processing.core.PApplet.run(PApplet.java:1674)
at java.lang.Thread.run(Thread.java:1019)
The same files work fine when they are in my data/assets folder included in the app...
Is there something I should know about setting the path via a String ??
Any thoughts appreciated,
Jesse
1