Nokia SDK(S60デバイス)のJ2MEでコードを記述しようとしていますが、Eclipseを使用しています。プリフェッチ前にJ2MEプレーヤーオブジェクトがハングアップする
コードは、プロジェクトの「res」ディレクトリ内に配置されたwavファイルを再生しようとします。コードは次のとおりです。
InputStream in1 = null;
System.out.println("ABout to play voice:" + i);
try {
System.out.println("Getting the resource as stream.");
in1 = getClass().getResourceAsStream(getsound(i));
System.out.println("Got the resouce. Moving to get a player");
}
catch(Exception e) {
e.printStackTrace();
}
try {
player = Manager.createPlayer(in1, "audio/x-wav");
System.out.println("Created player.");
//player.realize();
//System.out.println("Realized the player.");
if(player.getState() != player.REALIZED) {
System.out.println("The player has been realized.");
player.realize();
}
player.prefetch();
System.out.println("Fetched player. Now starting to play sound.");
player.start();
in1.close();
int i1 = player.getState();
System.out.println("Player opened. Playing requested sound.");
//player.deallocate();
//System.out.println("Deallocated the player.");
}
catch(Exception e) {
e.printStackTrace();
}
}
ここで、関数getSoundは、再生するファイルの名前を含む文字列を返します。以下のようになります:私は10の以上のサウンドを追加しようとすると 1.、アプリケーション全体がプリフェッチ()関数が呼び出される直前にハング:
private String getSound(int i) {
switch(i) {
case 1: return "/x1.wav";
case 2: return "/x2.wav";
}
}
私の問題は、これがあります。システム全体はしばらくの間かなり減速します。私はその後、アプリケーションを再起動する必要があります。
これをデバッグしようとしましたが、これまでのところ解決策がありませんでした。もし私がこれについて助けを得ることができれば素晴らしいだろう。