×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    6

    Cannot get sound

    I used the example as follows:

    InputStream is =
    getClass().getResourceAsStream("moo.wav");
    try {

    Player p =Manager.createPlayer(is, "audio/x-wav");
    p.prefetch();
    p.start();
    }
    catch (Exception e){
    System.out.println("aäänitulostevirhe");
    e.printStackTrace();
    }


    file moo.wav is in the Jar file for the project.
    is remains null and no sound comes
    Playsound works

    What is wrong?

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

    Re: Cannot get sound

    Welcome to Forum Nokia!

    When using getResourceAsStream(), always use a complete path, starting with "/". Make sure you have the correct path, so "/moo.wav" or "/res/moo.wav", or something else, depending on where the file is in the JAR. The method returns null when the file is not found.

    Graham.

  3. #3
    Registered User
    Join Date
    Dec 2010
    Posts
    6

    Re: Cannot get sound

    Thank you for help.
    i got the is working. Noe I get follwing error in p.start();

    "Prefetch failed, Symbian OS error: -5"

    Urpo

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

    Re: Cannot get sound

    Can you realize() the Player?

    On what device are you trying this?

    Check the "audio/x-wav" is correct for this device, by checking:

    Code:
    String[] types = Manager.getSupportedContentTypes(null);
    Ensure that the file is a valid WAV, and is 8kHz, 8bit, mono.

    Graham.

  5. #5
    Registered User
    Join Date
    Dec 2010
    Posts
    6

    Re: Cannot get sound

    Thank you Graham!

    I got it working with another wav file: wolf21.wav.

    Now I have to find out how to recognise the files of right type.

    Urpo

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

    Re: Cannot get sound

    What type of file is it...?

Similar Threads

  1. Can't play sound in Sound Tab — Series 40 Theme Studio 2.2 — says: no sound support
    By alex_inside in forum Tools and SDK Feedback (Closed)
    Replies: 0
    Last Post: 2007-09-03, 20:56
  2. Sound Duration (S40, com.nokia.sound.Sound)
    By srx3 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2004-10-10, 14:43
  3. 6600 - Call test during sound playback causes sound not to play any more
    By hdazza in forum General Development Questions
    Replies: 0
    Last Post: 2004-08-27, 15:59
  4. Standard sound (nokia 7650 an rest), duration = 3000 and sound is short, why ?
    By robon in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2003-07-22, 09:51
  5. Replies: 0
    Last Post: 1970-01-01, 02:00

Posting Permissions

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