views:

57

answers:

0

Hi

I'm having problem when taking a picture using VideoControl.getSnapshot() method. it always throw the exception: getSnapshot not Supported. Im using JRE 5.0.0 with Eclipse and BlackBerry® Java® SDK 5.0 Plugin.

What I do first is to list the encoding supported by Blackberry SmartPhone selected (bold 9700) with the command System.getProperty("video.snapshot.encodings") and select one encoding from the list and pass it as the getSnapshot argument.

I've tested on several Blackberry and the same exception is thrown.

Part of the code:

mPlayer = Manager.createPlayer("capture://video?encoding=video/3gpp");

mPlayer.realize();

mPlayer = Manager.createPlayer("capture://video?encoding=video/3gpp");

mPlayer.start();

videoControl = (VideoControl)mPlayer.getControl("VideoControl");

Field cameraView = (Field) videoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");

Thread.sleep(1000);

UiApplication.getUiApplication().pushScreen(new TempScreen(cameraView));

byte[] snapShot = videoControl.getSnapshot("encoding=jpeg&width=480&height=360&quality=superfine");

Bitmap image = Bitmap.createBitmapFromBytes(snapShot, 0, snapShot.length, 1);

UiApplication.getUiApplication().pushScreen(new TempScreen(image));

}catch (MediaException e){ UiApplication.getUiApplication().pushScreen(new TempScreen("Exception: " + e.getMessage())); }

catch (IOException e){ UiApplication.getUiApplication().pushScreen(new TempScreen("IO Exception: " + e.getMessage())); }

catch (InterruptedException e){UiApplication.getUiApplication().pushScreen(new TempScreen("Interrupted Exception: "+ e.getMessage()));}