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

Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified

Capture Thumbnails from Video

[ Edited ]

I would to load a video, and capture images at certain points in the video.


So far, I load the video into a player, create a video control and use the getSnapshot function in order to get the raw bytes.


First problem


The videoControl has to be set to "full screen" and added to a "video field" in order to actaully catpure any data - I don't want to do this because I'd ilke the "thumbnails" to load without the actual video being loaded.


Second problem


When I try to convert the bytes given back from getSnapshot to either a Bitmap or EncodedImage, the app gets IllegalStateException.


String file = System.getProperty("fileconn.dir.memorycard");

file += "BlackBerry/videos/VID-20120918-00001.MP4";
Player _player = javax.microedition.media.Manager.createPlayer(file);
VideoControl videoControl = (VideoControl) _player.getControl("VideoControl");
Field videoField = (Field) videoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");




catch (InterruptedException e)

byte[] imgraw = videoControl.getSnapshot("encoding=jpeg");



EncodedImage encodedImage = EncodedImage.createEncodedImage(imgraw, 0, imgraw.length);

Bitmap bmp = Bitmap.createBitmapFromBytes(imgraw, 0, imgraw.length, 0); BitmapField bf = new BitmapField(encodedImage.getBitmap()); deleteAll(); add(bf);