문제

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top