My database has a lot of short audio that formatted base64. I want to play audio when the button is on clicking. Basically, I wrote this code but it doesn't work. (If it possible, The file had better doesn't writing to storage because this process have a delay)
playButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try{
String url = "data:audio/mp3;base64,"+base64FormattedString;
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource(url);
mediaPlayer.prepare();
mediaPlayer.start();
}
catch(Exception e){
e.printStackTrace();
}
}
});
And the stacktrace is here: https://gist.github.com/AliAtes/aa46261aba3d755fbbd1eba300356a5f