×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Feb 2007
    Posts
    29

    WAV AMR playback inconsistancy.

    I tried all day to get a wav file to play and discovered that

    Code:
    Player player = Manager.createPlayer(getClass().getResourceAsStream("ktbado.wav"), "audio/x-wav");
    works, but

    Code:
    InputStream is = getClass().getResourceAsStream("ktbado.wav");
                   Player player = Manager.createPlayer(is, "audio/x-wav");
    doesnt. I am very confused by this as they are the same thing basically. Is it an issue with the io API ?

    Furthermore, when i change the file to a .amr file and use

    Code:
     InputStream is = getClass().getResourceAsStream("left.amr");
                   Player player = Manager.createPlayer(is, "audio/amr");
    or

    Code:
    Player player = Manager.createPlayer(getClass().getResourceAsStream("left.amr"), "audio/amr");
    The emulator gives me "MediaException cannot create a Player for audio/amr"
    The phone (Nokia E50) gives me "MediaExceptionPrefetch error: -5"

    Sigh. This has been a rough day (3 lines of code written =) ).

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

    Re: WAV AMR playback inconsistancy.

    amr is supported on that device. What is the bit rate for that file?

    Hartti

  3. #3
    Registered User
    Join Date
    Feb 2007
    Posts
    29

    Re: WAV AMR playback inconsistancy.

    I tried two 4.75k and 27.5 k , what does the bitrate make a difference for? I saw that there is amr-wb (or something ) but that file extension is .awb.


    I really don't get it. It just works. After reading about a zillion things for a few days, it just worked.

    I decided to write this and see what was supported.

    Code:
        String[] contentTypes = Manager.getSupportedContentTypes(null) ;
                Properties.insert(0,contentTypes[0],null);
                
                
                  for (int x = 0  ; x < contentTypes.length  ; x++)
                  { 
                    Properties.insert(x,contentTypes[x],null);
                    
                  }
    I ran that saw that mp3 was supported then i ran this:

    Code:
     Player player = Manager.createPlayer(getClass().getResourceAsStream("left.mp3"), "audio/mpeg");
            player.start();
    This didnt work (obviously since video/mpeg exists not audio/mpeg)
    so I changed the /mpeg to /mp3 and guess what? It worked. Then I changed the type to /amr and used the same "left.amr" and it worked.

    Im putting this down to the compiler being bad. I cant explain it.

  4. #4
    Registered User
    Join Date
    Jun 2007
    Posts
    28

    Re: WAV AMR playback inconsistancy.

    Hi adamzieba,
    i tried to play Mp3 file in both ways but its not playing, so oculd you please tell me what should i do.

    my code is :

    ..
    ..
    ..

    try {

    player = Manager.createPlayer(getClass().getResourceAsStream("frogs.mp3"),"audio/mp3");
    player.realize();

    // get the volume control
    volume = (VolumeControl)player.getControl("VolumeControl");

    // initialize it to 50
    volume.setLevel(50);

    // initialize the gauge
    gauge.setValue(volume.getLevel());
    gauge.setLabel("Volume: " + volume.getLevel());

    player.setLoopCount(2);

    player.start();

    form.setTitle("Playing " + locator);

    } catch(Exception e) {
    e.printStackTrace();
    }}
    ..
    ..
    ..


    when i am trying to run this code so i am getting Exception:

    Running with locale: English_United Kingdom.1252
    Running in the identified_third_party security domain
    javax.microedition.media.MediaException: Cannot create a Player for: audio/mp3
    at javax.microedition.media.Manager.getPlayerFromType(+52)
    at javax.microedition.media.Manager.createPlayer(+35)
    at javax.microedition.media.Manager.createPlayer(+53)
    at AudioPlayerCanvas.playMedia(+15)
    at Midlet.commandAction(+219)
    at javax.microedition.lcdui.List.callKeyPressed(+80)
    at javax.microedition.lcdui.Display$DisplayAccessor.keyEvent(+198)

  5. #5
    Registered User
    Join Date
    Feb 2007
    Posts
    29

    Re: WAV AMR playback inconsistancy.

    Did you try the code which I said worked ?

    Code:
    Player player = Manager.createPlayer(getClass().getResourceAsStream("ktbado.wav"), "audio/x-wav");
    player.start();
    Funnily enough... Now that i test the code, my emulator crashes

    Code:
    java.lang.OutOfMemoryError
    Are you trying it on the emulator or the phone? As far as I can see. The emulator only supports very few things, audio/x-wav is one of them.

Similar Threads

  1. Nokia 6111 cant play wav or amr files
    By ed_welch in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2006-11-21, 15:14
  2. convert an AMR file to WAV
    By analau2006 in forum Audio
    Replies: 2
    Last Post: 2005-02-04, 15:30
  3. Audio Converter in Java (AMR, WAV, MIDI,...)
    By ankames in forum General Messaging
    Replies: 0
    Last Post: 2004-01-25, 19:28
  4. WAV to AMR converter API
    By nellymoser in forum General Messaging
    Replies: 3
    Last Post: 2003-06-13, 06:49

Posting Permissions

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