Hello,
I was developing an Android App for over 4 months and now im struck into a problem with some Methods since my old Processing version crashed.
I used some Android librarys to play sounds in my App but now it seems like Processing isnt able to find some Methods the Android SDK contains.
My Code to Play Sounds:
import android.media.MediaPlayer;
import android.content.res.*;
MediaPlayer player, player_1, player_2, player_3, player_4, player_5;
AssetManager assets;
AssetFileDescriptor fd;
void setup(){
//Sounds
player = new MediaPlayer();
player_1 = new MediaPlayer();
player_2 = new MediaPlayer();
player_3 = new MediaPlayer();
player_4 = new MediaPlayer();
player_5 = new MediaPlayer();
assets = this.getAssets();
try {
fd = assets.openFd("song.wav");
player.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
player.prepare();
fd = assets.openFd("gameover.wav");
player_1.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
player_1.prepare();
fd = assets.openFd("victory.wav");
player_2.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
player_2.prepare();
fd = assets.openFd("arc.wav");
player_3.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
player_3.prepare();
fd = assets.openFd("explosion.wav");
player_4.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
player_4.prepare();
fd = assets.openFd("gamemusic.wav");
player_5.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
player_5.prepare();
}
catch (IOException e) {
e.printStackTrace();
}
catch (IllegalArgumentException e) {
e.printStackTrace();
}
catch (IllegalStateException e) {
e.printStackTrace();
}
}
In Processing 2.2.1 everything worked fine but after it crashed i had to install Android 3.0.1 to use Android Mode and now it seems like Processing had a Problem with the line " assets = this.getAssets();" as it reports :,, the function getAssets() does not exist" like it wasnt able to use some of the Android librarys. I tried to reinstall Processing and the Android Mode but nothing has changed. I know that the Error is not just about the sound, as im also not able to use other SDK Code to include e.g. Admob.
I’m working with API Level 6.0.
I hope someone can help me because I have no idea what I can do now to get it working again.
Thank You!!