1

Nokia SDK (S60 デバイス) の J2ME でコードを記述しようとしていて、Eclipse を使用しています。

このコードは、プロジェクトの "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 は、再生するファイルの名前を含む文字列を返します。それは次のとおりです。

private String getSound(int i) {
   switch(i) {  
     case 1: return "/x1.wav";
     case 2: return "/x2.wav";
   }
}

私の問題は次のとおりです。 1. 10 を超えるサウンドを追加しようとすると、prefetch() 関数が呼び出される直前にアプリケーション全体がハングします。しばらくの間、システム全体が大幅に遅くなります。その後、アプリケーションを再起動する必要があります。
これをデバッグしようとしましたが、これまでのところ解決策はありません。これについて少しでもお役に立てれば幸いです。

4

1 に答える 1

1

問題は、プロジェクトに使用されているエミュレータにあります。[実行構成] ウィンドウの [エミュレーション] タブで、次の [デバイス] を選択する必要があります。

グループ: Nokia N97 SDK v1.0
デバイス: S60 エミュレータ

Sun Java Wireless Toolkit の下にリストされているデバイスから上記に変更すると、問題は解決しました。

于 2011-01-25T15:48:20.223 に答える