Using Sound in Android

I’m trying to use apwidgets and I don’t understand why what I’m doing isn’t working.
I downloaded apwidgets_r44_for_Java1.5.zip and extracted it, and moved the apwidgets folder into the libraries folder for processing.
The gist of my code is this:

import apwidgets.*;
APMediaPlayer player;

void setup() {
    player = new APMediaPlayer(this);
    player.setMediaFile("file.mp3");
    player.start();
}
public void onDestroy() {
  super.onDestroy();
  if (player!=null) {
    player.release();
  }
}

There are no errors in processing itself, but when I run it, I get this error:

FATAL EXCEPTION: Animation Thread
Process: xyz.crispycabot.hold_the_touch, PID: 18688
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/xyz.crispycabot.hold_the_touch-oLOKRaPnDnSce8vCYHCoEA==/base.apk)
	at apwidgets.APMediaPlayer.setMediaFile(APMediaPlayer.java:81)
	at xyz.crispycabot.hold_the_touch.Hold_The_Touch.setup(Hold_The_Touch.java:92)
	at processing.core.PApplet.handleDraw(Unknown Source:75)
	at processing.core.PSurfaceNone.callDraw(Unknown Source:19)
	at processing.core.PSurfaceNone$AnimationThread.run(Unknown Source:55)

1 Like

I don’t think it is receiving any maintenance. Can you see if there is any date related to when it was last modified? Did you get it from github or from other repo? Check the old forum for MediaPlayer sample codes.

Kf

apwidgets does not work anymore(since 2 or 3 years) with P5…

1 Like

@akenaton Is there any way I could so sound then? That’s the only thing I could find that appeared to work