我有以下代码:
InputStream stream = (InputStream)this.getClass().getResourceAsStream("/preview.mp3");
Player p = Manager.createPlayer(stream, "audio/mpeg");
p.realize();
p.prefetch();
p.setLoopCount(-1);
VolumeControl volume = (VolumeControl) p.getControl("VolumeControl");
volume.setLevel(1);
p.start();
然后当我调用 stopAlarm()
// Stop playing music
void stopAlarm()
{
try
{
// Tell player to stop playing
p.stop();
}
catch (Exception e)
{
Dialog.alert("Error stopping music");
}
// Then release the data and close out the player
p.deallocate();
p.close();
}
简而言之,它不会停止音频。
如果有人可以帮助我解决这个问题,我将不胜感激。