Hi,
I am trying to play some audio in a j2me app. I send a request for an audio file, after I recieve the response, I start a player and play the audio file :
ByteArrayInputStream is = new ByteArrayInputStream(b);
p = Manager.createPlayer(is,"audio/midi");
p.realize();
p.prefetch();
p.start();
The Player p is declared globally.
After the player starts playing the audio, the value of 'p' becomes null.
So, in my 'keyPressed' method :
if (p != null) {
if (p.getState() == Player.STARTED)
{
p.stop();
p.deallocate();
}
} catch ( Exception ex) {
ex.printStackTrace();
System.out.println(ex.toString());
}
The control never reaches p.stop, as p is always equal to null.
Is there any other way to control audio in j2me ?
Thanks in advance.

Reply With Quote

