Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 49
Registered: ‎03-06-2009
My Device: Not Specified

Snapshot support for blackberry.

I develop a sample video player which play an .avi file on Blackberry 9000 emulator.

 

I want to get a snapshot of the playing movie, I write code for this as

 

_player.start();

videoControl.setVisible(true);

videoControl.setDisplaySize(screenWidth , screenHeight - (screenHeight / 4));

videoControl.setDisplayLocation(0,screenHeight / 8);

_player.start();

byteArr = videoControl.getSnapshot(System.getProperty("encoding=jpeg"));//video.snapshot.encodings"

 

But it give me an exception as "VideoControl.getSnapshot not supported" 

So please tell me the supported encodings to take a snapshot of playing movie.

 

Or if any other way please suggest that.

 

Thanks. 

                     

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: Snapshot support for blackberry.

This worked for me.

 

InputStream fis = getClass().getResourceAsStream("sample.3gp"); player = Manager.createPlayer(fis, "video/3gpp"); player.realize(); videoControl = (VideoControl)player.getControl("VideoControl"); videoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field"); videoControl.setVisible(true); ---------------------------------------------- byte x[] = videoControl.getSnapshot(System.getProperty("encoding=jpeg")); System.out.println("Lenght is "+x.length);

 

 

 


Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 49
Registered: ‎03-06-2009
My Device: Not Specified

Re: Snapshot support for blackberry.

Thanks,

 

I got the Byte array from the snapshot.

But I am getting exception while creating an bitmap from bytearray as IllegalArgumentException.

 

 

try{ //image = EncodedImage.createEncodedImage(byteArr, 0 , -1); bitmap = Bitmap.createBitmapFromBytes(byteArr,0,-1,1); //g.drawBitmap(0, 0, bitmap.getWidth(), bitmap.getHeight(), bitmap, 0, 0); }catch(Exception e){ g.drawText("Exception "+e.toString(),0,20,Graphics.LEFT|Graphics.TOP); }

 What are the mistecks in my code ?

 

 

Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: Snapshot support for blackberry.

Why are you using -1, you ahve to provide the length of the byte array.

 

image = EncodedImage.createEncodedImage(byteArr, 0 , byteArr.length);
bitmap = Bitmap.createBitmapFromBytes(byteArr,0,byteArr,1);

 


Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 49
Registered: ‎03-06-2009
My Device: Not Specified

Re: Snapshot support for blackberry.

[ Edited ]

     -1 used to get whole byte array 

 

//image = EncodedImage.createEncodedImage(byteArr, 0 , byteArr.length);

bitmap = Bitmap.createBitmapFromBytes(byteArr,0,byteArr.length,1); 

 

and I also try your suggestion but same error occured. 

 

Is there any 3 rd party jar can I use to play video. 

Message Edited by prashantkspatil on 03-12-2009 03:37 PM
Highlighted
Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: Snapshot support for blackberry.

This KB article tells how to play video.

 

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/1089414/How_To...

 

Is there anything specific reason you looking for thirtparty API to play video.

 

Did you test taking snapShot on device?


Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 49
Registered: ‎03-06-2009
My Device: Not Specified

Re: Snapshot support for blackberry.

[ Edited ]

playing video is not my problem.

 

I am not getting an image

image = EncodedImage.createEncodedImage(byteArr, 0 , byteArr.length);

 

from byteArr which I got as

byteArr = videoControl.getSnapshot(System.getProperty("encoding=jpg"));

 

I am using simulator 9000 bold 2.10, I  dont have device.

I want to show the image when video is pause. 

 

When I get a snapshot of video it return me byte array of 230400 length while the movie original width and height is 180*294 does this may cause to throw exception of IllegalArgumentException.

 

Please help me 

Message Edited by prashantkspatil on 03-13-2009 11:45 AM
BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Snapshot support for blackberry.

Using only encoding=jpeg is not valid.  You can use the System.getProperty method to read available encodings.  Here is what is returned from a version 4.6.0 BlackBerry Bold Simulator.

 

encoding=rgb565

encoding=jpeg&width=1600&height=1200&quality=superfine

encoding=jpeg&width=1600&height=1200&quality=normal

encoding=jpeg&width=1600&height=1200&quality=fine

encoding=jpeg&width=1024&height=768&quality=normal

encoding=jpeg&width=1024&height=768&quality=fine

encoding=jpeg&width=1024&height=768&quality=superfine

encoding=jpeg&width=640&height=480&quality=normal

encoding=jpeg&width=640&height=480&quality=fine

encoding=jpeg&width=640&height=480&quality=superfine

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: Snapshot support for blackberry.

Similar thread with Solution.

 

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&thread.id=25582


Use Search. "Accept Solution" If the problem is resolved.
Developer
Posts: 117
Registered: ‎02-12-2009
My Device: Not Specified

Re: Snapshot support for blackberry.

Hi,

 

I am using Storm simulator. And i am getting the encoding properties as mentioned above.

 

I checked the Main Camera Application there we have Color Effect options (Sepia, Black and White etc) also.

 

How can we add this support programmatically in camera demo?

 

Thanks,

Sandeep