J2ME, stop play after pressed button
Hello
I do alarm clock, but I have problem with stop play after pressing Stop button.
Thank you for your help
Code:
public void commandAction(Command c, Displayable s)
{
try {
Player player = Manager.createPlayer(getClass().getResourceAsStream("/ele.wav"), "audio/x-wav");
player.setLoopCount(3);
player.prefetch();
if ( c == cmExit)
{
destroyApp(true);
notifyDestroyed();
}
if( c == cmActive)
{
player.start();
}
if (c == cmCancel)
{
player.stop();
}
}
catch (Exception e) {
e.printStackTrace();
}
}
Re: J2ME, stop play after pressed button
Re: J2ME, stop play after pressed button
This is a forum. Please share the solution.
Or do you visit a forum only to get and never to give?
db
Re: J2ME, stop play after pressed button
I'm sorry
In Midlet
Code:
private Player player;
In startApp()
Code:
try {
player = Manager.createPlayer(getClass().getResourceAsStream("/ele.wav"), "audio/x-wav");
player.setLoopCount(3);
player.prefetch();
} catch (IOException ex) {
ex.printStackTrace();
} catch (MediaException ex) {
ex.printStackTrace();
}
}
And commandAction
Code:
public void commandAction(Command c, Displayable s)
{
if ( c == cmExit)
{
destroyApp(true);
notifyDestroyed();
}
if( c == cmActive)
{
try {
player.start();
} catch (MediaException ex) {
ex.printStackTrace();
}
}
if (c == cmCancel)
{
try {
player.stop();
} catch (MediaException ex) {
ex.printStackTrace();
}
}
}