×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    24

    using multiple players in a single J2ME app

    i'm facing the following problem in a J2ME game, on the S40 series:
    i've created an instance of a Player which plays a simple tone sequence after every valid move in a board game. in case an invalid move is made then i simply use AlertType.ERROR.playSound to indicate the warning to the user.
    the problem is that the validPlayer works perfectly fine initially, but the moment an invalid move is made, then it ceases to play after the subsequent valid move.
    the AlertType for invalid move however is unaffected. this problem is appearing only on the S40 series and emulator. there is no such problem on the WTK emulator nor the Samsung or Motorola emulators.
    could someone throw some light on this?

    ~ayush

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: using multiple players in a single J2ME app

    Hi ayush,

    you can check if multiple tones can be played simultaneously by checking the "supports.mixing" System property. If it returns "true", then, as reported on this Wiki page:
    * At least two tones can be played with Manager.playTone simultaneously.
    * Manager.playTone can be used at the same time when at least one Player is playing back audio.
    * At least two Players can be used to play back audio simultaneously.
    Hope it helps,
    Pit

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    24

    Re: using multiple players in a single J2ME app

    the problem is not that of playing multiple players simultaneously. at a given time only one player is required to play - following a valid move (validPlayer) and following an invalid move (AlertType.Error) . also, since there is a fair interval of time before successive moves, the Player plays the media track to completion well before the next call to the player.start()
    what is happening here is that validPlayer plays properly each time there is a valid move. however once the AlertType.Error kicks in, the validPlayer is unable to play after that. i caught the MediaException and the getMessage returns the string "Player not Active". after some more testing, i found that the validPlayer returns to the REALIZED state once the AlertType.Error plays. i managed to solve the problem last night by simply testing the state of the player before playing it. and if it is in the REALIZED state, then i explicitly call the validPlayer.prefetch() before starting. this did solve the problem but it also throws another question - as far as i know, the player.start() method on a REALIZED player implicitly calls the prefetch() method. so why should it be necessary to call the prefetch() method explicitly?
    btw, are there any specifications / restrictions of wav files that must be adhered to while using it for J2ME? for example, i've come across a number of wav clips that play alright on the PC, but do not play on the mobile phone. (each of these clips is less than 5kb so i dont think file size is an issue. furthermore i have often been able to play wav files upto 10-12kb in size).

    ~ayush



    Quote Originally Posted by jappit View Post
    Hi ayush,

    you can check if multiple tones can be played simultaneously by checking the "supports.mixing" System property. If it returns "true", then, as reported on this Wiki page:


    Hope it helps,
    Pit

Similar Threads

  1. Can we call a j2me app from Native C++ app
    By inguvaseshu in forum Symbian
    Replies: 3
    Last Post: 2009-01-13, 16:42
  2. Changing App Mgr settings from J2ME app
    By ddbhasin in forum Mobile Java General
    Replies: 6
    Last Post: 2007-09-21, 07:18
  3. Multiple socketconnections in j2me.
    By niempi2 in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2007-08-09, 14:19
  4. start-up j2me app in symbian app
    By IsGoldenFinger in forum Symbian
    Replies: 5
    Last Post: 2007-05-05, 12:56
  5. J2ME app works fine in the emu but not on the Communicator
    By schneidc80 in forum Mobile Java General
    Replies: 7
    Last Post: 2005-12-26, 15:16

Posting Permissions

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