Hi firend,
I'm using MMAPI in one of my application to play audio file from resource .But while prefetching it is throwing "java.lang.StringIndexOutOfBoundsException: String index out of range: -1" .
Can anyone give me some idea,why it is throwing this application error ?
And how to recover this problem?
code:
try
{
String loc = "/vibrate.mid";
InputStream is = getClass().getResourceAsStream(loc);
player = Manager.createPlayer(is,"audio/midi");
player.realize();
player.prefetch();
player.start();
}
catch (IOException ioe) {
al = new Alert("Alert","Error while enabling vibration using MMAPI(iMelody)invalid URL or InputStream cannot be formed.",imageError[0],AlertType.ERROR);
//wait for user to acknowledge the alert
al.setTimeout(Alert.FOREVER);
//Display alert,show main form when done
midlet.display.setCurrent(al,this);
System.err.println("Enable to vibrate using Nokia UI."+ioe);
}
catch (MediaException me) {
al = new Alert("Alert","Error while enabling vibration using MMAPI(iMelody)Player cannot be created.",imageError[0],AlertType.ERROR);
//wait for user to acknowledge the alert
al.setTimeout(Alert.FOREVER);
//Display alert,show main form when done
midlet.display.setCurrent(al,this);
System.err.println("Enable to vibrate using Nokia UI."+me);}
catch( Exception e ){
al = new Alert("Alert","Error while enabling vibration using MMAPI(iMelody).",imageError[0],AlertType.ERROR);
//wait for user to acknowledge the alert
al.setTimeout(Alert.FOREVER);
//Display alert,show main form when done
midlet.display.setCurrent(al,this);
System.err.println("Enable to vibrate using Nokia UI."+e);
}
Regards,
Sachin Warang.

Reply With Quote

