Hey guys,
I am developing a J2ME MIDlet for a S40 device (Nokia 6212).
My MIDlet needs to play a mp3 file every once in a while. This is my code that plays the file from the resource:
protected Player m_player = null;
public void playMP3Sound(String file_name) {
if (null != m_player) {
m_player.deallocate();
}
try {
InputStream in = getClass().getResourceAsStream(file_name);
m_player = Manager.createPlayer(in,"audio/mpeg");}
catch(Exception e) {
return;
}
try
{
m_player.prefetch();
m_player.start();
}
catch(Exception e){
}
}
This code works. The problem is that after around 40 files (they are all around 10-20 KB in size and around 1-2 seconds in duration) are being played, the application throws
an OutOfMemory exception and exits. Can someone see anything wrong with my code? Anything that needs
deallocation?
Thanks a lot!

Reply With Quote


