Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User enxebreman's Avatar
    Join Date
    Nov 2004
    Posts
    9
    Hi. I'm new in developing J2ME games and now I'm programming a game which has to play several MIDI sounds in Nokia 5140.
    This is my code:

    - I create the player in the constructor of a class named SoundManager (it also implements PlayerListener):

    InputStream is = getClass().getResourceAsStream("/audio/disparar.mid");
    firePlayer = Manager.createPlayer(is, "audio/midi");
    firePlayer.addPlayerListener(this);

    - And the code to play the sound is this:

    if (currentPlayer != null) {
    currentPlayer.stop();
    currentPlayer.deallocate();
    while (playing) {}
    }
    currentPlayer = firePlayer;
    firePlayer.realize();
    firePlayer.prefetch();
    firePlayer.start();
    playing = true;


    public void playerUpdate(Player player, String str, Object obj) {
    if (str == PlayerListener.END_OF_MEDIA) {
    playing = false;
    } else if (str == PlayerListener.STOPPED) {
    playing = false;
    }
    }


    It works for Nokia 6230 emulator, but when I take it to the Nokia 5140 it crashes and shows a java.lang.NullPointerException.

    Does anyone knows what is wrong in my code?
    or
    Could anyone tell me how to do this?

    Can Nokia 5140 play MIDI sounds or only wav ones?

  2. #2
    Nokia Developer Champion njzk2's Avatar
    Join Date
    Mar 2005
    Location
    Paris
    Posts
    814
    to know what are the supported media types, use the method getSupportedContentTypes(the protocol you are using (probably resource));
    it will give you the types you can play with your 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
  •  
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