×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    May 2007
    Location
    jakarta, indonesia
    Posts
    14

    playin' midi in Nokia failed

    i want to ask something about my java MIDlet.

    i made an application that will play song (midi)
    i created player to play the inputstream that contain the midi file.
    but when i tested it in Nokia 6600 and Nokia 3230, it failed to play.
    after i choose the "play song" menu, it suddenly freezed.
    (even though i had no prob playing the song in nokia 6575--CDMA phone)

    what's the problem?

    thanks in advance..

    p.s : FYI, i used MIDP 2.0 & CLDC 1.0 for N6600 & N3230 (i used CLDC 1.1 but the MIDlet cannot be installed into phone)

  2. #2
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,429

    Re: playin' midi in Nokia failed

    May be you could give a try with this code.
    ...
    try {
    InputStream is = getClass().getResourceAsStream("/Test.mid");
    Player player = Manager.createPlayer(is, "audio/midi");
    player.realize();
    player.prefetch();
    player.start();
    }
    catch(IOException ioe) {
    }
    catch(MediaException me) {
    }
    ...

    Also ensure that sound enabled profile is selected. Are you getting any exceptions in the real device?

    Regards
    Gopal

    __________________
    MobiQuil.com
    An initiative by Developers for Developers.
    http://www.mobiquil.com - Alpha - Launched.

  3. #3
    Registered User
    Join Date
    May 2007
    Location
    jakarta, indonesia
    Posts
    14

    Re: playin' midi in Nokia failed

    i used this code as follow :
    ----
    void sing()
    {
    try
    {
    InputStream is = getClass().getResourceAsStream("/moka.mid");
    songPlayer = Manager.createPlayer(is, "audio/midi");
    songPlayer.realize();
    songPlayer.prefetch();
    songPlayer.start();
    }
    catch ( Exception e )
    {
    e.printStackTrace();
    }
    }
    -----
    1. in keypress, when i press the play song menu, it'd run this code
    if(keyCode == -5)
    this.parent.play();
    2. play() is located in Main.java
    public void play()
    {
    playSong = new PlaySong(this);
    display.setCurrent(playSong);
    }
    (playSong already declared above constructor)
    3. in PlaySong.java i used this function :
    protected void showNotify()
    {
    readLyrics();
    reconstructLyrics();
    timer = new Timer();
    timer.schedule(headerAnim, 0, 750);
    bolHeadAnim = true;
    songThread = new Thread(this);
    songThread.start();
    //animationThread = new Thread(this);
    //animationThread.start();
    }
    is there any line in this showNotify that can cause my nokia handset to freeze?
    FYI, i tested my midlet in other phone and it can seem to work alright...
    after the keypress what i want the midlet to do is :
    -play the midi song
    -play animation (i used timer & timertask)

    let me post the code that paint the animation
    class HeaderAnimation extends TimerTask
    {
    public void run()
    {
    animate();
    }
    }
    void animate()
    {
    bolHeadAnim = true;
    if(animState < 4)
    animState++;
    else
    animState = 1;
    repaint();
    }
    in the function paint(Graphics g)
    if(bolHeadAnim && animState > 0 && animState <= 4)
    {
    g.drawImage(imgAnim[animState-1], 0, 0, 0);
    bolHeadAnim = false;
    }

    thanks anyway

    p.s : no exception at all in the phone

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×