开发者

j2me audio player

开发者 https://www.devze.com 2023-04-10 06:45 出处:网络
I created a audio player using following code. try { InputStream is = getClass().getResourceAsStream(\"bell.wav\");

I created a audio player using following code.

try {

    InputStream is = getClass().getResourceAsStream("bell.wav");

    player = Manager.createPlayer(is, "audio/X-wav");

    player.realize();

    player.prefetch();
    player.start();


}
catch (IOException ex) {
 开发者_如何转开发   ex.printStackTrace();

}
catch (MediaException ex) {
    ex.printStackTrace();

}

This code works on the simulator without any problem. But it is not working in the phone. MediaException is thrown. I think phone does not support for this player. Have there any solutions for this ?


It might help to check what mime types are supported by the device by checking

Manager.getSupportedContentTypes(String protocol);

and

Manager.getSupportedProtocols(String content_type);

You can also try using an URL instead of InputStream

Manager.createPlayer(String url);
0

精彩评论

暂无评论...
验证码 换一张
取 消