I have code that creates smaller wav file "events" from one larger wav file based on energy levels.
Depending on the structure of the orignial wav file the amount of wav file events created will vary.
I would like to create a dynamic amount of play buttons for each event that will play each event out loud.
The method to create an event has the following signature:
public void createEventWav(ArrayList<Double> event, String fileName, Context context) {
This will create a wav file with a unique filename.
This is the code I have currently that plays an event:
public Button playEvent;
playEvent= (Button) findViewById(R.id.btnPlayEvent);
playEvent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
playEvent( );
}
});
public static void playEvent(){
try {
MediaPlayer player = new MediaPlayer();
player = new MediaPlayer();
player.setDataSource("/data/data/com.example.androidaudiorecorder/files/recording_DOG.wav");
player.prepare();
player.start();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (Exception e) {
System.out.println("Exception of type : " + e.toString());
e.printStackTrace();
}
I would like to have one for each event created.
Please see attched for layout of app
I have already tried many of the solutions found at : How to add a button dynamically in Android?
None have worked so far.