I am trying to develop a language learning app where I play dialog lines on a button click (5-10 seconds each).
So, I created arrays of dialog lines for each dialog, i.e:
currentAudioArray {"line0", "line2", "line3"}
They are names of the audio files placed in res/raw folder
But I can't get to play them the way I need. I am using MediaPlayer.create() method, but it seems that it only takes direct links to specific files (i.e. R.raw.mySoundfile).
How can I feed an array usingsomething like looping [i] into MediaPlayer.create()? Or is there any other class or method to play a next audio file on a NEXT button click?
So far I tried using: mediaPlayer= MediaPlayer.create(Listen.this, currentAudioArray[0])); mediaPlayer.start();
But it gives me "unresolved method" error because it does not like currentAudioArray[0] being a string and not URL.
I also tried: mediaPlayer.setDataSource(currentAudioArray[0])
but this also gives arrows once it gets to mediaPlayer.prepare().
Any suggestions or ideas on how to play those files in array are very very welcome!