Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor sachinwarang's Avatar
    Join Date
    Mar 2006
    Posts
    76
    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.

  2. #2
    Nokia Developer Champion hartti's Avatar
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,192
    Could it be that the problem is in the catch clause? So that there is an exception thrown at some point and when you are handling the exception you happen to throw another exception (this time for StringIndexOutOfBound)
    Could you try replacing the System.err.println("..." + e); with System.err.println("..." + e.toString()); or the whole statement with a simple e.printStackTrace()

    Hartti

Similar Threads

  1. problem when stop playing video on 3650 and try to play again
    By niko86 in forum Mobile Java General
    Replies: 5
    Last Post: 2007-08-03, 07:40
  2. netcards - Problem with opening adapter
    By kernj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-01-10, 08:56
  3. problem with video capture on 6630 (MMAPI)
    By sbwoodside in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2004-12-15, 11:06
  4. MMAPI problem on N-Gage/3650
    By bajwa_78 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2004-10-30, 06:59
  5. Camera snapshot very poor quality with MMAPI
    By vmarchese in forum Mobile Java Media (Graphics & Sounds)
    Replies: 7
    Last Post: 2003-09-13, 01:15

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved