English 中文(简体)
j2me probleming with multi sound file
原标题:j2me problem with playing multiple sound files

I have a problem with playing more than 2 sound files in a game I m developing now in j2me MIDP2 in eclipse. Please advice me the best way for playing multiple "wav" sound files. I created the following method that is called once when the program starts

public void setSound()
        {
            System.out.println("Sound on");
            try {
                p1=Manager.createPlayer(is1, "audio/X-wav");
                p2=Manager.createPlayer(is2, "audio/X-wav");
                p3=Manager.createPlayer(is3, "audio/X-wav");
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (MediaException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

我每次都需要打响声音之一,就停止其他两个角色(确保其中任何一方都不会运行p2.stop(); p3.stop();并开始第三者(p1.start();,每次我有两名参与者(在PREFETCHED国家里)停职,第三人没有工作,有例外。

问题回答

Java ME光谱并不具体,但在实际装置上,你通常只拥有一个分配的参与者,因此仅仅阻止参与者是不够的。 See also this Forum post。 我发现,甚至很难在玩,新的角色之前适当安排参与者的位置,例如。 我在试图玩弄新东西之前,先去等待一个声音。

在j2me,只有一名参与者。 超过1个参与者没有得到支持。 • 如何在他人或他人之后执行声音。 如果乌想要打上多种声音,那么乌将遵循以下编码。

public class AudioPlayer implements javax.microedition.media.PlayerListener{

Player player;
int count=0;

public void playMedia(){

try{

player = Manager.createPlayer(getClass().getResourceAsStream(audioFiles[count]),"audio/x-amr");
player.addPlayerListener(this);
player.start();

}
catch (Exception e) {
return ;
}
}


public void playerUpdate(Player p,String event,Object eventData) 
{

        //Playing next audio file after completion of current audio.
}

}




相关问题
add text in http request string url

ok i made a midlet through which i can connect to server pages and get soem information as response. For example i made a midlet through which i acced url: http://example.com/?u=nepal&t=1 Now i ...

Do I have to do a setSize() on a Vector before using it?

Given private final Vector v = new Vector(); //instance variable the following 3 lines are in an instance method in the same class. 1. int length = v.capacity(); 2. int size = v.size(); ...

Is the situation with Java ME improving?

It seems to be the consensus that developing for Java ME is not as cross platform as you might expect, particularly compared to say java SE, but it is difficult to assess how the situation is evolving....

Privileged operations in netbeans mobility

I m writing a Java ME app that will use privileged operations such as messaging. By default the user is prompted to confirm each of these operations, but I would like to run it as a background ...

ClassFormatError: 56 while using hessian in j2me

I am trying to use the hessian j2me implementation @ http://hessian.caucho.com/ using java me sdk 3.0. http://hessian.caucho.com/doc/hessian-overview.xtp#Hessian%20Client%20for%20a%20cell-phone ...

热门标签