I need to run my sounds and music (OGG files) on my phone but the code (a book's code to play it on android studio) does not run on my phone (it runs but says unfortunately stops on the phone). I am using eclipse luna I found on the web. I also import libraries I think I am using but I do not really know much of them. This is the similar code (so I hide real names and specify on sound):
package processing.test.something;
import processing.core.*;
import processing.data.*;
import processing.event.*;
import processing.opengl.*;
import java.util.HashMap;
import java.util.ArrayList;
import java.io.File;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
// Added imports I thought were usefull here
import android.media.AudioManager;
import android.media.SoundPool;
import android.content.Context;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
public class something extends PApplet {
private SoundPool soundPool;
int song = -1;
void setup() {
soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);
try {
AssetManager assetManager = getAssets(); //I clicked generate method because getAssets() was labeled as an error.
AssetFileDescriptor descriptor;
descriptor = assetManager.openFd("song.ogg");
song = soundPool.load(descriptor, 0);
} catch (IOException e) {
}
soundPool.play(song, 1, 1, 0, 0, 1);
} // End of setup()
private AssetManager getAssets() {
// TODO Auto-generated method stub
return null;
}
void draw() {
}
} // End class something
The console does not print errors. I do not know if it is a type of sketch permission or I am making something incomplete. How can I fix this code?