views:

325

answers:

2

Hi all,

i am developing one j2me application to play wav & mp3 file.

problems are:

  • while try to play mp3 file in my phone (nokia 5610d) it is making "Out of memory" error.
  • while try to play Wav file it is giving "Sounds are not allowed" exception.

few lines of my code is here.

Code to play Wav file

InputStream is = getClass().getResourceAsStream("/Child.wav");
player = Manager.createPlayer(is, "audio/x-wav");

player.realize(); player.start();

Code to play MP3 file

InputStream is = getClass().getResourceAsStream("/Child.mp3");<br/>
player = Manager.createPlayer(is, "audio/mpeg");

player.realize(); player.start();

Please let me know what is the problem in my code.

A: 

Does it make any difference if you call player.prefetch(); before player.start();? All the examples I have seen previously are done this way.

Also try using the mime type audio/mp3 instead if audio/mpeg doesn't work.

James
A: 

You might want to try "audio/wav" instead of "audio/x-wav".

I would also suggest using a FileConnection URL (Manager.createPlayer("file://localhost/E:/MyFolder/Child.mp3"); for example) as that typically works better than Players created with an InputStream on Series40 phones.

QuickRecipesOnSymbianOS