×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    3

    How to increse/decrese the Application sound volume without stopping the sound

    Hi all,
    I am creating a Game using J2ME.In that , in setting screen user can increse or decrese the sound volume using left-right key navigation. Actually i have done this using the below code:
    vc = (javax.microedition.media.control.VolumeControl) p.getControl("VolumeControl");
    if (vc != null)
    {
    vc.setLevel(volCnt);
    }
    volCnt is a integer value.I have increased/decresed this value using left/right key. But after alter this value i need to stop the sound and again need to start. Actually i want to increase/decrese the sound volume with out stopping the sound which is playing currently on the application(Only the sound volume value has to change).
    Please help me to find a solution as soon as possible.

    Thanks
    Regards,
    Malli.

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

    Re: How to increse/decrese the Application sound volume without stopping the sound

    First, my experience with using volume control is that generally it does not work well (across a large range of devices). For this reason, you will find that many commercial games do not contain a volume setting.

    If you do want a volume control, don't expect too much of it. I suggest:

    * Don't play sound in the "settings" screen. Have a short sound, which you play every time sound is switched on, and every time the volume is changed, to provide the user with a sample.

    * Many devices will provide only a limited number of distinct volume levels (for example, 4). Don't offer more than four volume levels.

    * On some devices, it just won't work, so make sure that the volume setting can be removed easily, without major code changes.

    My opinion is that the volume control is best left to the phone's own settings.

    My other sound-related tip: beware of playing looped music. It can cause havoc if the application is interrupted by a call.

    Cheers,
    Graham.

  3. #3
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: How to increse/decrese the Application sound volume without stopping the sound

    Quote Originally Posted by mallirajan View Post
    Hi all,
    I am creating a Game using J2ME.In that , in setting screen user can increse or decrese the sound volume using left-right key navigation. Actually i have done this using the below code:
    vc = (javax.microedition.media.control.VolumeControl) p.getControl("VolumeControl");
    if (vc != null)
    {
    vc.setLevel(volCnt);
    }
    volCnt is a integer value.I have increased/decresed this value using left/right key. But after alter this value i need to stop the sound and again need to start. Actually i want to increase/decrese the sound volume with out stopping the sound which is playing currently on the application(Only the sound volume value has to change).
    Please help me to find a solution as soon as possible.

    Thanks
    Regards,
    Malli.
    Hi,
    Well what Grahm is saying can be correct,I am using the word "can be" since I have used it alot in games and it works fine,for me.

    Now as far as your issue is concern, there can be some problem and the same can be fixed by looking into the code,
    For your reference I putting my own code,you use ti and let me know -
    @ Initialized the media file
    public void initMedia()
    {
    try
    {
    InputStream is;

    is = getClass().getResourceAsStream("/prizes.wav");
    musicCollidePrizes = Manager.createPlayer(is, "audio/X-wav");
    musicCollidePrizes.realize();

    }

    catch(Exception ioe)
    {

    }
    }

    @ make the things ready,
    public void playMedia()
    {
    try
    {

    if(music.getState() != Player.REALIZED)
    {
    music.realize();

    }
    if(music.getState() != Player.PREFETCHED)
    {

    music.prefetch();

    }
    vc = (VolumeControl) music.getControl("VolumeControl");

    if(vc != null)
    {

    vc.setLevel(RealCanvas.volumeIndex);

    }

    music.start();

    }
    catch(Exception ioe)
    {

    }
    }
    @ Then play the media,
    @ Then control the volume -
    increase/decrease the volumeIndex on the left/Right key pressed and then
    do not forgot the line
    sounds.setVolume( volumeIndex);

    please check the concept,
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  4. #4
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: How to increse/decrese the Application sound volume without stopping the sound

    Hi,
    Just check the code/concept line by line with your code,
    I am sure that there is something wrong
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    3

    Re: How to increse/decrese the Application sound volume without stopping the sound

    Hi,
    Thank You very much for ur Kind Reply..

    Regards,
    Malli.

Similar Threads

  1. Sound Volume n73
    By rpillet in forum Symbian Media (Closed)
    Replies: 0
    Last Post: 2006-08-23, 13:24
  2. suppressing sound of message which comes for j2me application
    By vickychhabra in forum General Messaging
    Replies: 0
    Last Post: 2003-07-05, 14:42
  3. 7650 Java application crashes when calling sound API
    By gameskitchen in forum Mobile Java General
    Replies: 3
    Last Post: 2002-12-09, 21:31
  4. filtering application as a recipient?
    By aidj in forum General Messaging
    Replies: 1
    Last Post: 2002-11-12, 06:26

Posting Permissions

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