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
Regular Contributor
Posts: 62
Registered: ‎04-06-2011
My Device: Blackberry developer
My Carrier: Blackberry developer

VideoControl = null

[ Edited ]

Hi again Smiley Wink

 

I cant make the player works in a field. I have searched a lot of places and everyone gives the same example that don't works for me.

 

This is the code I try:

InputStream inputStream = null;
		HttpConnection conn;
		String apendix = ConnectionUtilities.getConnectionMethodParameter();
		try {
			conn = (HttpConnection)Connector.open(url+apendix);
			inputStream = conn.openInputStream();
		} catch (IOException e1) {
			Dialog.inform("Error connection");
		}

		Player _player = null;
		try {
			_player = javax.microedition.media.Manager.createPlayer(inputStream,"audio/mpeg");
		} catch (IOException e1) {
			Dialog.inform("Error create player 1");
		} catch (MediaException e1) {
			Dialog.inform("Error create player 2");
		}
                                                                 
		try {
			_player.realize();
		} catch (MediaException e1) {
			Dialog.inform("Error realize");
		}

		//Add listener to catch Player events 
		_player.addPlayerListener(this);
		
		//Get the Player VideoControl 
		VideoControl _videoControl = (VideoControl) _player.getControl("javax.microedition.media.control.VideoControl");
		
		if(_videoControl==null){
			Dialog.inform("VideoControl = null");
		}

 

The error that i get is a nullPointerException when i try to do

 

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

before i get my Dialog.inform("VideoControl = null"), so the problem is that i cannot get the control of the player... Why i get this error?? I'm running in 4.6.1, but i have read that there is no problem to run player in 4.6.1, isn't it?

 

Thanks all for you great help, you are helping me a lot to start developing blackberry app.

 

Albert

Highlighted
Developer
Posts: 146
Registered: ‎07-24-2008
My Device: none
My Carrier: none

Re: VideoControl = null

HI Albert
You are passing "audio/mpeg" as MIME type, so it assume it as an audio file. Thats why its returning null videofiled.
The process you followed is accurate and standard.
Try with some video format and it should work.

Thanks
Ankit
Thanks & Regards,
Ankit Dubey
Module Lead Software Engineer, mLabs
Impetus InfoTech (India) Pvt. Ltd.
Regular Contributor
Posts: 62
Registered: ‎04-06-2011
My Device: Blackberry developer
My Carrier: Blackberry developer

Re: VideoControl = null

Thank for your response.

I will try and I'll tell you Smiley Happy

 

But what can i do if i want to play mp3?? It's not possible?

 

Thanks! Smiley Happy

 

Albert

Regular Contributor
Posts: 62
Registered: ‎04-06-2011
My Device: Blackberry developer
My Carrier: Blackberry developer

Re: VideoControl = null

Ok, it worked with video file!! Smiley Very Happy
But now it apears in the screen but the video don't reproduce.
What kind of videos can Blacbkerry play??
I have tried with Avi file. In the browser says it is "video/x-msvideo" MIME type. Must I put this type of content, or I must put "video/avi"??

Thanks!

Albert
Developer
Posts: 146
Registered: ‎07-24-2008
My Device: none
My Carrier: none

Re: VideoControl = null

hi
did you call videoControl.setVisible(true); method?
video/avi should do the job, also look in to the Manager class API .

Thanks
Ankit
Thanks & Regards,
Ankit Dubey
Module Lead Software Engineer, mLabs
Impetus InfoTech (India) Pvt. Ltd.
Regular Contributor
Posts: 62
Registered: ‎04-06-2011
My Device: Blackberry developer
My Carrier: Blackberry developer

Re: VideoControl = null

Yes, I call videoControl.setVisible(true), and really it apears in the screen as a Black field, but the movie don't start.
Is because it must be in an specific codec?
And the last question i did, is there some option to play music?

Thanks, Smiley Happy

Albert
Developer
Posts: 146
Registered: ‎07-24-2008
My Device: none
My Carrier: none

Re: VideoControl = null

the same above code applies for music, just you do not have any video control for that.

Thanks
Ankit
Thanks & Regards,
Ankit Dubey
Module Lead Software Engineer, mLabs
Impetus InfoTech (India) Pvt. Ltd.
Developer
Posts: 146
Registered: ‎07-24-2008
My Device: none
My Carrier: none

Re: VideoControl = null

This is the code snippet which i used earlier, you can try the same


_player = Manager.createPlayer(inputstream,mimeType);
_player.realize();
_vc = (VideoControl) _player.getControl("VideoControl");
VolumeControl volume = (VolumeControl) _player.getControl("VolumeControl");
if(volume != null)volume.setLevel(100);
if (_vc != null) {
_videoField = (Field) _vc.initDisplayMode(
VideoControl.USE_GUI_PRIMITIVE,
"net.rim.device.api.ui.Field");
_vc.setDisplaySize(480, 300);
UiApplication.getUiApplication().invokeLater(
new Runnable() {
public void run() {
add(_videoField);
}
});
_vc.setVisible(true);
}
_player.start();

Thanks
Ankit
Thanks & Regards,
Ankit Dubey
Module Lead Software Engineer, mLabs
Impetus InfoTech (India) Pvt. Ltd.
Regular Contributor
Posts: 62
Registered: ‎04-06-2011
My Device: Blackberry developer
My Carrier: Blackberry developer

Re: VideoControl = null

[ Edited ]

I do more or less the same than you.

but what video codec and what mimetype did you use?

 

thanks for your help,

 

Albert

Developer
Posts: 146
Registered: ‎07-24-2008
My Device: none
My Carrier: none

Re: VideoControl = null

well in my case it was fixed video/mp4.

Ankit
Thanks & Regards,
Ankit Dubey
Module Lead Software Engineer, mLabs
Impetus InfoTech (India) Pvt. Ltd.