3
다음 코드를 작성했습니다. 카메라 플레이어를 만드는 데 사용됩니다. 나는 노키아 폰으로 테스트했다. 잘 작동하고 카메라를보고 기능을 사용할 수 있습니다.삼성 전화에서 j2me의 카메라를 열 수 없습니다.
하지만 문제는 삼성 휴대 전화에서 코드를 테스트 할 때 미디어 예외가 발생하고 결국 애플리케이션에서 나가야한다는 것입니다. 이 코드로 인해 내장 된 카메라 기능 (예 : 삼성 휴대 전화)도 작동하지 않습니다. 그래서 그 이유는 무엇입니까?
public void startCamera()
{
try
{
try
{
// if player==null
player = createPlayer();
}
catch (Exception ex)
{
ex.printStackTrace();
ErrorDialog.show(ex, "We are exiting the application.",
"Exit", new com.auric.qrev.scanqrcode.lwuit.ui.Action(){
public void actionPerformed() {
m_objMIDlet.exitApp();
}
});
}
try
{
player.realize();
player.prefetch();
}
catch (MediaException ex)
{
ex.printStackTrace();
ErrorDialog.show(ex, "We are exiting the application.",
"Exit", new com.auric.qrev.scanqrcode.lwuit.ui.Action(){
public void actionPerformed() {
m_objMIDlet.exitApp();
}
});
}
//Grab the video control and set it to the current display.
videoControl = (VideoControl)(player.getControl("VideoControl"));
if (videoControl == null)
{
//discardPlayer();
stopCamera();
ErrorDialog.show("Unsupported:\n"+
"Can't get video control\n"+
"We are exiting the application.",
"Exit", new com.auric.qrev.scanqrcode.lwuit.ui.Action(){
public void actionPerformed() {
m_objMIDlet.exitApp();
}
});
}
mediaComponent = new MediaComponent(player);
mediaComponent.setFocusable(false);
m_cameraScreen.showCamera(mediaComponent);
start();
}
catch(Exception ex)
{
ex.printStackTrace();
//discardPlayer();
stopCamera();
ErrorDialog.show("Sorry,Resources unavailable.\nWe are exiting the application.",
"Exit", new com.auric.qrev.scanqrcode.lwuit.ui.Action(){
public void actionPerformed() {
m_objMIDlet.exitApp();
}
});
}
}
private Player createPlayer()throws MediaException, Exception
{
Player mPlayer = null;
// try capture://image first for series 40 phones
try
{
mPlayer = Manager.createPlayer("capture://image");
}
catch (Exception e)
{
e.printStackTrace();
}
catch (Error e)
{
e.printStackTrace();
}
// if capture://image failed, try capture://video
if (mPlayer == null)
{
try
{
mPlayer = Manager.createPlayer("capture://video");
}
catch (Exception e)
{
e.printStackTrace();
throw new MediaException("Sorry,Resources unavailable.");
}
}
if(mPlayer == null)
throw new Exception("Sorry,Resources unavailable.");
return mPlayer;
} 첫번째
그래서 예외는 무엇입니까? 예외 처리 접근법에 대해 작업해야합니다 ... – home
예외 처리가 의미하는 것은 ... 예외가 발생한 곳을 확인할 수 없습니다 (어쩌면'if (mPlayer == null)'입니까? – home
"리소스를 사용할 수 없습니다. 응용 프로그램을 종료합니다."라는 미디어 예외가 발생했습니다. –