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
Blanc
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified
Accepted Solution

Embed video into my screen

[ Edited ]

Hi all,

 

I have a problem of embedding video into a screen with fields.

I just want to make screen with the video and play, stop and pause buttons.

 

The following is code for my player screen. I added the necessary fields and the video control but once the player starts playing the video is playing in a separate screen.

 

Am unable to hold control on the video. Play, Pause, Stop buttons are remaining useless and they are not visisble even.

 

I just gone through the samples of devResources

 

http://supportforums.blackberry.com/t5/Java-Development/Sample-Code-How-to-add-video-to-your-UI/ta-p...

 

but no use.

 

 

 

 

public PlayerScreen(String vUrl)
{

super(NO_VERTICAL_SCROLL);

imgPause = Bitmap.getBitmapResource("playerImages/Button_Pause.png");
imgPlay = Bitmap.getBitmapResource("playerImages/Button_Play.png");
isplay = true;

btnPlay = new BitmapField(imgPause,BitmapField.FOCUSABLE|ButtonField.CONSUME_CLICK)
;

imgStop = Bitmap.getBitmapResource("playerImages/Button_Stop.png");
btnStop = new BitmapField(imgStop,BitmapField.FOCUSABLE|ButtonField.CONSUME_CLICK)
;

imgReplay = Bitmap.getBitmapResource("Button_Replay.png");
btnReplay = new BitmapField(imgReplay,BitmapField.FOCUSABLE|ButtonField.CONSUME_CLICK)
;

playerMenuLayer = Bitmap.getBitmapResource("playerImages/Button_Background.png");
bottomBar = Bitmap.getBitmapResource("surveyimages/bgseat.png");
bottomBar = ResizeImage.resizeBitmap(bottomBar, AppConstants.DEVICE_DISPLAY_WIDTH, 50);

Thread thread = null;

try
{

_player = Manager.createPlayer(vUrl);
_player.addPlayerListener(this);
_player.realize();
_videoControl = (VideoControl)_player.getControl("VideoControl");
if(_videoControl != null)
{

_videoField = (Field)_videoControl.initDisplayMode(0, "net.rim.device.api.ui.Field");
_videoControl.setDisplaySize(AppConstants.DEVICE_DISPLAY_WIDTH, AppConstants.DEVICE_DISPLAY_HEIGHT-(27+bottomBar.getHeight()));

_videoControl.setVisible(true);
}
add(_videoField);

UiApplication.getUiApplication().invokeLater(new Runnable()
{

public void run()
{
try
{
_player.prefetch();
_player.start();
}
catch(Exception e)
{
//GlobalSettings.setErrorLog(e.toString());
}
}

}, 1000L, false);

progressBar = new ProgressBar();
add(progressBar);

hfmBottom = new HorizontalFieldManager()
{
public void paint(Graphics graphics)
{
graphics.drawBitmap(0, 0,bottomBar.getWidth() ,bottomBar.getHeight(), bottomBar, 0, 0);
graphics.drawBitmap((bottomBar.getWidth()/2)-(playerMenuLayer.getWidth()/2),5,playerMenuLayer.getWidth() ,playerMenuLayer.getHeight(),playerMenuLayer,0,0);
super.paint(graphics);
}
};

hfmBottom.add(btnReplay);
hfmBottom.add(btnPlay);
hfmBottom.add(btnStop);

add(hfmBottom);
(thread = new Thread(this)).start();
}
catch(Exception e)
{
Tools.print("XCO: PlayerScreen: Error While playing media: " + e.toString());
}
}
protected void paint(Graphics graphics)
{
graphics.setBackgroundColor( 0x000000 );
graphics.clear();

// calling super.paint() will create the white background
// so instead we will call subpaint() ourselves
subpaint( graphics );
//super.paint(graphics);
}

public void run()
{
do
{
progressBar.update(_player.getState() == 400, (int)(_player.getMediaTime() / 0xf4240L), (int)(_player.getDuration() / 0xf4240L));
try
{
Thread.sleep(200L);
}
catch(Exception e) { }
} while(true);
}

 

 

 

Thanks and Regards,
PraveenGoparaju.
Please use plain text.
Developer
Blanc
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Re: Embed video into my screen

any updates friends!!!

 

 

Thanks and Regards,
PraveenGoparaju.
Please use plain text.
Developer
Blanc
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Re: Embed video into my screen

any ideas or any help ??

Thanks and Regards,
PraveenGoparaju.
Please use plain text.
Developer
Blanc
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Re: Embed video into my screen

Thanks friends!!!

 

Just to update, I have solved my issue.

 

I got motivated from the Blackberry media player, and I prepared the player that is near to BB media player ( not exactly matching.. :smileysad:  ).

 

I will share my code here.

Thanks and Regards,
PraveenGoparaju.
Please use plain text.
Contributor
sujayarun8
Posts: 48
Registered: ‎07-20-2010
My Device: Not Specified
My Carrier: developer

Re: Embed video into my screen

is your new player working...?? have u posted ur new code??

Please use plain text.
Developer
Blanc
Posts: 638
Registered: ‎07-02-2009
My Device: Not Specified

Re: Embed video into my screen

Please use plain text.