×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    7

    fail to play .mp3 file

    Hi,
    I would like to play a song in mp3 format. I have used "audio/mpeg", but it fails to play the song. The related code is in below.

    Private Player;
    InputStream in = getClass().getResourceAsStream("/Audio/background.mp3");

    try {
    player = Manager.createPlayer(in, "audio/mpeg");
    player.setLoopCount(-1);
    player.realize();
    player.prefetch();
    player.start();
    }
    catch (Exception e) {}
    Last edited by vinnahang; 2006-04-05 at 14:47.

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

    Re: I want to play .mp3, then "audio/??"

    Does the phone you are using support mp3 audio (on Java platform)?

    You are not checking that the InputStream returned from the getResourceAsStream() method is not null, so it could be that the file is not found.

    Also what is the line "Private Player;"?
    If that's the declaration of the variable "player" it should be something like "private Player player;"

    Hartti

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    7

    Re: I want to play .mp3, then "audio/??"

    Thz, Hartti,

    I use the SUN wireless tool kit to load the game. Do this simulator support .mp3?

    For the getResourceAsStream() method, although I didn't check it is null or not, I checked the file is in that directory manually. And I have tried to play .wav file, I placed the .wav file in the same directory of that .mp3 file, and I set player = Manager.createPlayer(in, "audio/x-wav"); the song can play. If the .mp3 I loaded into the simulator is too large in size, I have used a a shorter time with smaller size .mp3 file, it failed to load too. So I don't know what happen on .mp3?


    Sorry. I have a typo.
    The line should be Private Player player.

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

    Re: I want to play .mp3, then "audio/??"

    The User Guide for WTK (version 2.2) states that mp3 is not supported
    http://java.sun.com/j2me/docs/wtk2.2...i.html#wp22571

    Hartti

Similar Threads

  1. Recording in Amr Format
    By losym in forum Symbian Media (Closed)
    Replies: 12
    Last Post: 2009-03-26, 06:41
  2. To play raw audio data file
    By pawans in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2008-12-11, 11:38
  3. Nokia 3220 Wont play midi files. Support = 0
    By dreamcrawler in forum General Development Questions
    Replies: 0
    Last Post: 2005-03-12, 10:56
  4. Play more than one wav-Sound ?
    By IngeSchmidt in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2004-08-31, 17:46
  5. Load and play audio file
    By itenel in forum Symbian
    Replies: 4
    Last Post: 2004-05-17, 07:20

Posting Permissions

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