×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    4

    Jumping in MIDI files

    As I found out, that the Nokia6230 can handle only 1 player (only the first loaded midi will be played, the others will be ignored), I tried to create one midi containing all the effects and music for the game.
    If I want to play a given effect, I just jump to a given position in the midi. A least I try to...
    What I do is:


    //Init for my midi player
    public void init(){
    try
    {
    InputStream in = getClass().getResourceAsStream("/sound.mid");
    p = Manager.createPlayer(in, "audio/midi");
    p.prefetch();
    p.stop();
    p.deallocate();
    p.setMediaTime(0L);
    }
    catch (Exception e)
    { }
    }

    //this is what plays the sound
    public void play(long fromwhere){
    try
    {
    p.stop();
    p.setMediaTime((long)fromwhere);
    p.start();
    }
    catch (MediaException e)
    {e.printStackTrace(); }
    }

    Even if i jump with "fromwhere" to the end of the midi, it starts to play it from the beginning.

    Does anyone know how I can jump to any place in the midi correctly? - and play it from the given position

    Thank you in advance

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    10

    Re: Jumping in MIDI files

    Yea it seems that setMediaTime doesn't work with midi files.

  3. #3
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    87
    I'm certain that setMediaTime(long) does work on Nokias, the only MMAPI phone we found not to support this is the Motorola Triplets which actually throws an exception.

    Try performing a rewind() on the midi before setting the media time, I think that should do it, if not consult Nokia documentation.

  4. #4
    Registered User
    Join Date
    Nov 2004
    Posts
    16
    why you do the deallocate()???
    the player will back to UNREALIZED State!!!
    Please read the MIDP2.0 Doucment
    The following methods must not be used when the Player is in the UNREALIZED state.

    getContentType
    setMediaTime
    getControls
    getControl

Posting Permissions

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