I have a very simple implementation of MediaPlayer which works fine. For testing purposes, how can I force the code to throw an error? OnErrorListener must be invoked to test failure handling. TIA.
try {
player.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.start();
}
});
player.setOnErrorListener(new OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
/* handling code */
/* *********************** */
/* WANT THIS EVENT TO OCCUR BY FORCE */
/* *********************** */
}
});
player.prepareAsync();
}
catch(Exception e) {
e.printStackTrace();
}