I am developing a game in J2ME and I am using 4 different sound(midi) files in game. When I run this game on nokia device, it's showing too many players prefetched
exception. It's working fine in Samsung. How to resolve this?
Asked
Active
Viewed 510 times
3
-
You must accept answer for helping future views of the question. @shalini you have to click on the green tick of the correct answer. – frayab Jan 26 '12 at 12:46
2 Answers
4
I had the same problem and solved implementing a PlayerListener and deallocating sounds after play:
playbackPlayer = Manager.createPlayer(ttsConnection.getFileUrl());
PlayerListener pl = new PlayerListener() {
public void playerUpdate(Player player, String event, Object eventData) {
if (event.equalsIgnoreCase(PlayerListener.END_OF_MEDIA)
|| event.equalsIgnoreCase(PlayerListener.STOPPED)) {
player.close();
}
}
};
playbackPlayer.addPlayerListener(pl);
2
Cause :
Many devices have limits of how many sounds can be in the
prefetched
state at once.This differ with devices. On many S60s, for example, it's six ,on many other devices, it is only one.
Possible Solutions :
Realize
the players, but don'tprefetch
them - they'll beprefetched
automatically when they play.use a
PlayerListener
to deallocate the players after they play, to avoid holding too many in theprefetched
state.

COD3BOY
- 11,964
- 1
- 38
- 56