hi Vikram,
I've tested on S60 2nd ed FP 2 device: 6680
that code:
Code:
package tests;
import java.io.*;
import javax.microedition.media.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.media.control.*;
public class PlaySoundMidlet extends MIDlet implements CommandListener, Runnable {
public void startApp() {
if(mainScreen == null){
mainScreen = new Form("Play audio");
mainScreen.addCommand(new Command("Quit", Command.EXIT, 1));
mainScreen.addCommand(new Command("Play", Command.OK, 1));
mainScreen.setCommandListener(this);
}
Display.getDisplay(this).setCurrent(mainScreen);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
if(player != null){
player.close();
}
}
public void commandAction(Command command, Displayable displayable) {
if(command.getCommandType() == Command.EXIT){
Display.getDisplay(this).setCurrent(null);
destroyApp(false);
notifyDestroyed();
}else if(command.getCommandType() == Command.OK){
Thread t = new Thread(this);
t.start();
}
}
public void run() {
StringBuffer sb = new StringBuffer();
InputStream is = null;
try {
is = getClass().getResourceAsStream("/resources/AudioClip.amr");
if(is == null){
throw new IOException("cannot read resource file");
}
player = Manager.createPlayer(is, "audio/amr");
player.setLoopCount(5);
player.realize();
VolumeControl volume = (VolumeControl) player.getControl("VolumeControl");
player.start();
if(volume != null){
sb.append("volume: ").append(volume.getLevel()).append("\n");
int newLevel = volume.setLevel(100);
sb.append("new volume: ").append(volume.getLevel()).append("\n");
}
} catch (MediaException ex) {
sb.append(ex.getMessage()).append("\n");
} catch (IOException ex) {
sb.append(ex.getMessage()).append("\n");
} catch (Exception ex) {
sb.append(ex.getMessage()).append("\n");
} finally {
mainScreen.append(sb.toString());
sb = null;
}
}
private static Form mainScreen;
private static Player player;
}
and it plays just fine,
the same played on Nokia Prototype Emulator throws that error you've found,
hth,
regards,
Peter