The method below creates player and play mp3 file.
public void run()
{
try
{
InputStream is = getClass().getResourceAsStream("/your.mp3");
player = Manager.createPlayer(is,"audio/mpeg");
player.realize();
// get volume control for player and set volume to max
vc = (VolumeControl) player.getControl("VolumeControl");
if(vc != null)
{
vc.setLevel(100);
}
player.prefetch();
player.start();
}
catch(Exception e)
{}
}
Here you have given relative path which folder it corresponds to ?
ReplyDeleteit corresponds to resource folder
ReplyDeleteis there any one found some one that have used this code and fulfill their targets? this code is more popular but may not work.
ReplyDeleteit's not work.. please.. i have try anything to play.. but "audio/mpeg" is not work. Else, i've try "audio/mp3", "audio/mpeg-layer3"..
ReplyDeletePlease give THE RIGHT CODE!!
On my n6210 it works correctly. First of all you must check if getClass().getResourceAsStream("/your.mp3"); doesn't return null (maybe path is incorrect, try without "/"). Secondly check what formats you phone supports: String[] contents = Manager.getSupportedContentTypes(null);
ReplyDeleteMaybe you device doesn't support "audio/mpeg";
Cannot find installation of quicktime.
ReplyDeleteThis error is there.
how to overcome this?
can you give me the full code..??
ReplyDeletei am new in j2me..
Thank you sir...
ReplyDeleteOh no, please explain how to use, i've just seen this snippet at java-tips.org but cant make it work @@
ReplyDelete