×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    18

    Button Sound Problem

    Hi guys!

    I have created a simple game using J2ME. The game is working great and works on almost any J2ME phone because the graphics are highly scalable. I wanted to add a little sound, but this is giving me some problems.

    The game has a grid and a selector which is moved when the "keyPressed" method is fired. I have tried adding the following code into this method, and whilst the sound does in fact play, so does the default beep of the phone. I have tried removing "super.keyPressed(keyCode)", but this did not appear to make any difference.

    if (moveSoundPlayer != null) {
    try {
    moveSoundPlayer.setMediaTime(0);
    moveSoundPlayer.start();
    } catch(Exception ex) {
    // Sound failed, disable!
    moveSoundPlayer.deallocate();
    moveSoundPlayer = null;
    }
    }

    In my constructor I have:

    try {
    moveSoundPlayer = Manager.createPlayer(BoardDisplay.class.getResourceAsStream("move.wav"), "audio/x-wav");
    moveSoundPlayer.realize();
    moveSoundPlayer.prefetch();
    } catch(Exception ex) {
    if (moveSoundPlayer != null) {
    moveSoundPlayer.deallocate();
    moveSoundPlayer = null;
    }
    }

    How can I disable the default beep?

    Many thanks!
    Lea Hayes

    p.s. I am testing this on a "Nokia 6220 Classic" phone.

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Button Sound Problem

    You need to disable the sound in the phone's settings. You can't do it in code.

    Graham.

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    18

    Re: Button Sound Problem

    Hi Graham,

    When you say in the phone's settings, would this be via the JAD file? Or would users of the game be required to disable sound?

    I have played games made by other people on my phone and not had this problem. Are such games created using other development tools, perhaps even C++?

    Thanks,
    Lea

  4. #4
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Button Sound Problem

    The user needs to do this, manually.

    I don't know what other games you've seen. If you installed a ".sis" file, then yes, they're C++.

    Graham.

  5. #5
    Registered User
    Join Date
    Nov 2009
    Posts
    18

    Re: Button Sound Problem

    If I recall, the format was ".sisx", and it was a demo of a puzzle type game which I downloaded from the OVI store.

    Thanks for your advice. I will take investigate mobile development with C++; J2ME seems to lack several features that I require.

    If I develop mobile games using C++, do you know if the game would be limited to just Nokia phones, or will it also work on Sony, Android, and iPhone?

    Thanks!
    Lea

  6. #6
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: Button Sound Problem

    .sisx is a native, C++ program.

    If you develop in C++, your program will not even work on all Nokias... it will work only on Nokia's Series 60 devices (not on Series 40). Series 40 devices support only Java, as do most Sony Ericsson and Motorola devices.

    Android applications are usually written in its own, non-standard form of Java, while iPhone apps are built with Objective-C (using the iPhone SDK, which runs only on an Apple Mac).

    Graham.

  7. #7
    Registered User
    Join Date
    Nov 2009
    Posts
    18

    Re: Button Sound Problem

    Thanks for the info Graham, that is fantastic, and much appreciated!

    Lea Hayes

Similar Threads

  1. nokiaUI sound problem with MIDP 1.0 on Ngage
    By iLya in forum Mobile Java General
    Replies: 1
    Last Post: 2005-07-05, 02:41
  2. Problem with Sound class getState()
    By creepymo in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-06-20, 18:43
  3. MIDI Sound problem (J2ME / Series 60)
    By JPapke in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2004-10-29, 08:17
  4. No sound working on 6600 problem..
    By johan_olsson76 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2003-11-19, 15:30
  5. strange problem playing Sound on 7650
    By Poldipold in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2003-07-11, 13:12

Posting Permissions

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