×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    66

    setLevel(100) using VolumeControl causes RuntimeException

    Hello,

    I am using Carbide.j 1.5. When I use setLevel(100) of a VolumeControl control to set the volume to maximum possible, I get the following runtime exception:

    "java.lang.RuntimeException: java.lang.IllegalArgumentException:Requested value 13.0 exceeds allowable maximum value 6.0206."

    Anybody from Nokia know if this will be fixed soon and if this problem also exists on actual phones?

    I know this is a bug as setLevel(100) should set the volume to maximum possible and not cause a runtime exception. In fact, even if I set the Volume to 200 it should still work as per the MMAPI specification.

    Regards,
    Vikram Goyal
    http://www.mmapibook.com

  2. #2
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: setLevel(100) using VolumeControl causes RuntimeException

    hi Vikram,

    which of SDKs you've used (regular SDK or Prototype SDK) when testing that?
    have you tried to validate againts Sun WTK emulators?
    it could be important which SDK you've used because according to specs (MMAPI):
    The level scale specifies volume in a linear scale. It ranges from 0 to 100, where 0 represents silence and 100 represents the highest volume. The mapping for producing a linear multiplicative value is implementation dependent.
    that is implememtation computes end values according to setVolume arguments,

    regards,
    Peter

  3. #3
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    66

    Re: setLevel(100) using VolumeControl causes RuntimeException

    Quote Originally Posted by peterblazejewicz
    that is implememtation computes end values according to setVolume arguments
    That is exactly my point! As per the specification 100 should map to the highest level supported by the implementation. So if the highest level supported is 6, 100 should map linearly to 6.

    In fact, as per the specification, values over 100 should also map to the highest level of volume supported. It should not cause a RuntimeException.

    I have used Carbide.J 1.5 which I believe is regular SDK? Also, it works fine for Sun, Motorola and Sony Ericsson WTK's.

    Regards,
    Vikram Goyal
    http://www.mmapibook.com

  4. #4
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: setLevel(100) using VolumeControl causes RuntimeException

    hi Vikram,

    which SKD from those shipped with Carbide.j? (there are few for different platforms all as Nokia Prototype .... for different S## platforms)

    regards,
    Peter

  5. #5
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    66

    Re: setLevel(100) using VolumeControl causes RuntimeException

    Quote Originally Posted by peterblazejewicz
    hi Vikram,

    which SKD from those shipped with Carbide.j? (there are few for different platforms all as Nokia Prototype .... for different S## platforms)

    regards,
    Peter
    It doesn't matter. All SDK's give the same problem.

    Cheers,
    Vikram
    http://www.mmapibook.com

  6. #6
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: setLevel(100) using VolumeControl causes RuntimeException

    hi Vikram,

    I've tried such code with SDK Prototype 4.0 (from Carbide.j) for S60:
    Code:
    public void run() {
            InputStream is = null;
            try {
                is = getClass().getResourceAsStream("/resources/sample.wav");
                if(is == null){
                    System.out.println("cannot read resource file");
                    return;
                }
                player = Manager.createPlayer(is, "audio/x-wav");
                player.setLoopCount(5);
                player.realize();
                VolumeControl volume = (VolumeControl) player.getControl("VolumeControl");
                if(volume != null){
                    System.out.println("volume: "+volume.getLevel());
                    int newLevel = volume.setLevel(100);
                    System.out.println("new volume: "+newLevel);
                }
                player.start();
            } catch (MediaException ex) {
                ex.printStackTrace();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    and had no issues with VolumeControl.setLevel(...)
    as stated in MMAPI docs I've got correct data:
    volume: -1
    new volume: 100
    that is -1 if level was not yet set
    and 100 after setting level to 100,

    regards,
    Peter

  7. #7
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    66

    Re: setLevel(100) using VolumeControl causes RuntimeException

    Peter,

    This is weird! I have got same code (ok similar, setLevel can only be used one way!) and I get the exception as I said. I am running on the SDK that I download only days earlier.

    Vikram
    http://www.mmapibook.com

  8. #8
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Arrow Re: setLevel(100) using VolumeControl causes RuntimeException

    hi Vikram,

    yeah, strange enough,

    lets call for help
    // HELP WANTED GUYS//
    can someone also just run quick test (most part of code already posted) with Nokia Prototype 4 SDK emulator?

    we've already got different results which is frustrating enough,


    thanks in advance,
    regards,
    Peter

  9. #9
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    66

    Re: setLevel(100) using VolumeControl causes RuntimeException

    Quote Originally Posted by peterblazejewicz
    can someone also just run quick test (most part of code already posted) with Nokia Prototype 4 SDK emulator?
    Yes that would be good! Better still would be a response from the Nokia Team! The error that I have listed is very specific and should be easy to trace within the codebase.

    Cheers,
    Vikram
    MMAPI Book
    http://www.mmapibook.com

  10. #10
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: setLevel(100) using VolumeControl causes RuntimeException

    I compiled a test midlet based on Peter's code and I got no exceptions. Volume was set to 100 and sound was played.

    I have not seen this error reported in the error databases either.

    Hartti

  11. #11
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    66

    Re: setLevel(100) using VolumeControl causes RuntimeException

    Ok, so the only difference that I can see in the code is that I am trying to play an AMR file. Could you try with an AMR file and see if you get the same error?

    Vikram
    Author - MMAPI Book
    http://www.mmapibook.com

  12. #12
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: setLevel(100) using VolumeControl causes RuntimeException

    hi Vikram,

    are you setting level after player is started?
    e.g. that way:
    Code:
    player.start();
                if(volume != null){
                    System.out.println("volume: "+volume.getLevel());
                    int newLevel = volume.setLevel(100);
                    System.out.println("new volume: "+newLevel);
                }
    ?
    it causes:
    volume: 90
    MMA : com.nokia.mmedia.control.SVolumeControlException during remote invocation
    java.lang.RuntimeException: java.lang.IllegalArgumentException:Requested value 13.0 exceeds allowable maximum value 6.0206
    hinting to try amr file was good, it only happens when AMR file is played, not with .wav file,

    I've used sample "AudioClip.amr" file which comes with MMAPI sample (MediaSampler):
    http://www.forum.nokia.com/info/sw.n..._v1_0.zip.html
    its repeatable,
    it plays fine in S40 3rdEd FP1 SDK Emulator,

    regards,
    Peter

  13. #13
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    66

    Re: setLevel(100) using VolumeControl causes RuntimeException

    Excellent! This proves that there is a bug with the VolumeControl that is created for playing AMR files. It doesn't matter if I try to get this control after the player has started as that shouldn't make a difference. The control should be available after the player has been realized. So how do we get about getting this bug fixed? Does it happen in actual devices as well (I don't have a Nokia device)?

    Cheers,
    Vikram
    MMAPI Book
    http://www.mmapibook.com

  14. #14
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: setLevel(100) using VolumeControl causes RuntimeException

    hi Vikram,

    I've tested on S60 2nd ed FP 2 device: 6680
    that code:
    Code:
    package tests;
    
    import java.io.*;
    import javax.microedition.media.*;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.media.control.*;
    
    
    public class PlaySoundMidlet extends MIDlet implements CommandListener, Runnable {
        public void startApp() {
            if(mainScreen == null){
                mainScreen = new Form("Play audio");
                mainScreen.addCommand(new Command("Quit", Command.EXIT, 1));
                mainScreen.addCommand(new Command("Play", Command.OK, 1));
                mainScreen.setCommandListener(this);
            }
            Display.getDisplay(this).setCurrent(mainScreen);
        }
        
        public void pauseApp() {
        }
        
        public void destroyApp(boolean unconditional) {
            if(player != null){
                player.close();
            }
        }
        
        public void commandAction(Command command, Displayable displayable) {
            if(command.getCommandType() == Command.EXIT){
                Display.getDisplay(this).setCurrent(null);
                destroyApp(false);
                notifyDestroyed();
            }else if(command.getCommandType() == Command.OK){
                Thread t = new Thread(this);
                t.start();
            }
        }
        
        public void run() {
            StringBuffer sb = new StringBuffer();
            InputStream is = null;
            try {
                is = getClass().getResourceAsStream("/resources/AudioClip.amr");
                if(is == null){
                    throw new IOException("cannot read resource file");
                }
                player = Manager.createPlayer(is, "audio/amr");
                player.setLoopCount(5);
                player.realize();
                VolumeControl volume = (VolumeControl) player.getControl("VolumeControl");
                player.start();
                if(volume != null){
                    sb.append("volume: ").append(volume.getLevel()).append("\n");
                    int newLevel = volume.setLevel(100);
                    sb.append("new volume: ").append(volume.getLevel()).append("\n");
                }
            } catch (MediaException ex) {
                sb.append(ex.getMessage()).append("\n");
            } catch (IOException ex) {
                sb.append(ex.getMessage()).append("\n");
            } catch (Exception ex) {
                sb.append(ex.getMessage()).append("\n");
            } finally {
                mainScreen.append(sb.toString());
                sb = null;
            }
        }
        
        private static Form mainScreen;
        private static Player player;
        
    }
    and it plays just fine,
    the same played on Nokia Prototype Emulator throws that error you've found,


    hth,
    regards,
    Peter

  15. #15
    Regular Contributor
    Join Date
    Mar 2006
    Posts
    66

    Re: setLevel(100) using VolumeControl causes RuntimeException

    Thanks for confirming this Peter. The bug is not on the devices but in the emulators. I have tested on all the current emulators and get the error.

    Cheers,
    Vikram
    MMAPI Book
    http://www.mmapibook.com

Similar Threads

  1. HOW TO DEVELOP VOLUMECONTROL ON NAVIPANE
    By coxcom in forum Symbian
    Replies: 0
    Last Post: 2006-05-16, 04:40
  2. support for VolumeControl in 6230
    By mks@megansmitley.org in forum Audio
    Replies: 0
    Last Post: 2006-04-03, 16:49
  3. Volumecontrol on Nokia 6610
    By sjollema in forum General Development Questions
    Replies: 2
    Last Post: 2004-04-05, 14:53
  4. MMAPI: VolumeControl in Nokia 3650
    By caabeiro in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2003-11-24, 13:54
  5. VolumeControl in 3300
    By RichYen in forum Mobile Java General
    Replies: 0
    Last Post: 2003-06-27, 08:44

Posting Permissions

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