openFd crashes
in
Android Processing
•
1 year ago
Hello there.
I'm trying to use Audio in my Android-app. I know that there are already a lot of questions on the forum and elsewhere concerning Audio and Android, and I read a whole lot of them.
Currently I'm trying to use the built-in MediaPlayer, but everytime I try to load a soundfile with openFd, the console says
And I have to say, I have no idea why. Am I even using the right path? I have a data/assets folde in my sketch-folder.BUILD FAILEDC:\android-sdk\tools\ant\build.xml:679: The following error occurred while executing this line:C:\android-sdk\tools\ant\build.xml:692: Compile failed; see the compiler error output for details.
The current code is:
-
import android.media.*;import android.content.res.*;
MediaPlayer player;AssetManager assets;
void setup(){
size(720,1280);background(240);player = new MediaPlayer();assets = this.getAssets();AssetFileDescriptor fd;fd = assets.openFd("bassdr06.wav");player.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());player.prepare();
}
I have also seen a lot of people using the try { ... }. If I try to implement this into the code, it also stops compiling..
with regards.
1