Hi, I downloaded the apwidgets library so I can play sounds on my android phone, but it isn't quite working. I can import the library and declare a new APMediaPlayer variable, but if I so much as try to initialize it, it crashes as soon as it launches and I get this error:
FATAL EXCEPTION: Animation Thread
Process: processing.test.android_sound_test, PID: 5490
java.lang.NoSuchMethodError: No virtual method getAssets()Landroid/content/res/AssetManager; in class Lprocessing/core/PApplet; or its super classes (declaration of 'processing.core.PApplet' appears in /data/app/processing.test.android_sound_test-1/base.apk)
at apwidgets.APMediaPlayer.setMediaFile(APMediaPlayer.java:81)
at processing.test.android_sound_test.android_sound_test.setup(android_sound_test.java:28)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:762)
Here is my code, if it helps. It's basically the example in the wiki:
import apwidgets.*;
APMediaPlayer player;
void setup () {
fullScreen ();
player = new APMediaPlayer(this); //create new APMediaPlayer
player.setMediaFile("Hope you have a good day.mp3"); //set the file (files are in data folder)
player.setLooping(true); //restart playback end reached
player.setVolume(1.0, 1.0); //Set left and right volumes. Range is from 0.0 to 1.0
player.start(); //start play back
}
void draw () {
background (0);
}
public void onDestroy() {
super.onDestroy(); //call onDestroy
if (player != null) { //must be checked because or else crash when return from landscape mode
player.release(); //release the player
}
}